}
        $sql = appendSQL($sql, $tmp_extra = array('NoSearchTerms' => true));
        // extra must be lvalue
        $RET = DBGet(DBQuery($sql), array(), array('STUDENT_ID', 'SHORT_DATE'));
    }
    if (count($cal_RET)) {
        foreach ($cal_RET as $value) {
            $extra['SELECT'] .= ',\'\' as _' . str_replace('-', '', $value['SCHOOL_DATE']);
            $extra['columns_after']['_' . str_replace('-', '', $value['SCHOOL_DATE'])] = ShortDate($value['SCHOOL_DATE']);
            $extra['functions']['_' . str_replace('-', '', $value['SCHOOL_DATE'])] = '_makeColor';
            $extra['link']['FULL_NAME']['link'] = "Modules.php?modname={$_REQUEST['next_modname']}&day_start={$_REQUEST['day_start']}&day_end={$_REQUEST['day_end']}&month_start={$_REQUEST['month_start']}&month_end={$_REQUEST['month_end']}&year_start={$_REQUEST['year_start']}&year_end={$_REQUEST['year_end']}&period_id={$_REQUEST['period_id']}";
            $extra['link']['FULL_NAME']['variables'] = array('student_id' => 'STUDENT_ID');
        }
    }
    Widgets('course');
    Widgets('absences');
    $extra['new'] = true;
    Search('student_id', $extra);
    echo '</FORM>';
}
function _makeColor($value, $column)
{
    global $THIS_RET, $RET, $attendance_codes;
    if ($_REQUEST['period_id']) {
        if (!$attendance_codes) {
            $attendance_codes = DBGet(DBQuery('SELECT ID,DEFAULT_CODE,STATE_CODE,SHORT_NAME FROM attendance_codes WHERE SYEAR=\'' . UserSyear() . '\' AND SCHOOL_ID=\'' . UserSchool() . '\' AND TABLE_NAME=\'0\''), array(), array('ID'));
        }
        if ($attendance_codes[$RET[$THIS_RET['STUDENT_ID']][$column][1]['ATTENDANCE_CODE']][1]['DEFAULT_CODE'] == 'Y') {
            return "<TABLE bgcolor=#00FF00 cellpadding=0 cellspacing=0 width=10 class=LO_field><TR><TD>" . makeCodePulldown($RET[$THIS_RET['STUDENT_ID']][$column][1]['ATTENDANCE_CODE'], $THIS_RET['STUDENT_ID'], $column) . "</TD></TR></TABLE>";
        } elseif ($attendance_codes[$RET[$THIS_RET['STUDENT_ID']][$column][1]['ATTENDANCE_CODE']][1]['STATE_CODE'] == 'P') {
            return "<TABLE bgcolor=#FFCC00 cellpadding=0 cellspacing=0 width=10 class=LO_field><TR><TD>" . makeCodePulldown($RET[$THIS_RET['STUDENT_ID']][$column][1]['ATTENDANCE_CODE'], $THIS_RET['STUDENT_ID'], $column) . "</TD></TR></TABLE>";
    //	{
    //            $extra['extra_header_left'] .= '<TD><INPUT type=checkbox name=mp_arr[] value='.$mp['MARKING_PERIOD_ID'].'>'.$mp['SHORT_NAME'].'</TD>';
    //
    //	}
    //        $extra['extra_header_left'] .= '</TR></TABLE></TD></TABLE>';
    /*********************************************************************************/
    $extra['link'] = array('FULL_NAME' => false);
    $extra['SELECT'] = ",s.STUDENT_ID AS CHECKBOX";
    $extra['functions'] = array('CHECKBOX' => '_makeChooseCheckbox');
    $extra['columns_before'] = array('CHECKBOX' => '</A><INPUT type=checkbox value=Y name=controller checked onclick="checkAll(this.form,this.form.controller.checked,\'st_arr\');"><A>');
    $extra['options']['search'] = false;
    $extra['new'] = true;
    $extra['WHERE'] .= " AND s.STUDENT_ID IN (SELECT DISTINCT STUDENT_ID FROM student_standards)";
    Widgets('course');
    Widgets('gpa');
    Widgets('class_rank');
    Widgets('letter_grade');
    Search('student_id', $extra, 'true');
    if ($_REQUEST['search_modfunc'] == 'list') {
        echo '<BR><CENTER><INPUT type=submit class=btn_xxlarge value=\'Create Standard Report Cards for Selected Students\'></CENTER>';
        echo "</FORM>";
    }
}
function _makeChooseCheckbox($value, $title)
{
    return '<INPUT type=checkbox name=st_arr[] value=' . $value . ' checked>';
}
function _makeTeacher($teacher, $column)
{
    return substr($teacher, strrpos(str_replace(' - ', ' ^ ', $teacher), '^') + 2);
}
Exemple #3
0
#  This program is released under the terms of the GNU General Public License as
#  published by the Free Software Foundation, version 2 of the License.
#  See license.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#***************************************************************************************
include '../../Redirect_modules.php';
Widgets('request');
Widgets('mailing_labels');
$extra['force_search'] = true;
if (!$_REQUEST['search_modfunc'] || $_openSIS['modules_search']) {
    DrawBC("" . _('Scheduling') . " > " . ProgramTitle());
    $extra['new'] = true;
    $extra['action'] .= "&_openSIS_PDF=true&head_html=Student+Print+Request";
    $extra['pdf'] = true;
    Search('student_id', $extra);
} else {
    $columns = array('COURSE_TITLE' => '' . _('Course') . '', 'MARKING_PERIOD_ID' => '' . _('Marking Period') . '', 'WITH_TEACHER_ID' => '' . _('With Teacher') . '', 'WITH_PERIOD_ID' => '' . _('In Period') . '', 'NOT_TEACHER_ID' => '' . _('Not with Teacher') . '', 'NOT_PERIOD_ID' => '' . _('Not in Period') . '');
    $extra['SELECT'] .= ',c.TITLE AS COURSE_TITLE,c.COURSE_ID,srp.PRIORITY,srp.MARKING_PERIOD_ID,srp.WITH_TEACHER_ID,srp.NOT_TEACHER_ID,srp.WITH_PERIOD_ID,srp.NOT_PERIOD_ID';
    $extra['FROM'] .= ',courses c,schedule_requests srp';
    $extra['WHERE'] .= ' AND ssm.STUDENT_ID=srp.STUDENT_ID AND ssm.SYEAR=srp.SYEAR AND srp.COURSE_ID = c.COURSE_ID';
    $extra['functions'] += array('WITH_FULL_NAME' => '_makeExtra');
    $extra['group'] = array('STUDENT_ID');
    if ($_REQUEST['mailing_labels'] == 'Y') {
    }
    Search('student_fields', is_array($extra['student_fields']) ? $extra['student_fields'] : array());
    if (User('PROFILE') == 'admin') {
        echo '<CENTER><INPUT type=checkbox name=_search_all_schools value=Y' . (Preferences('DEFAULT_ALL_SCHOOLS') == 'Y' ? ' CHECKED' : '') . '><font color=black>Search All Schools</font></CENTER><BR>';
    }
    echo '<CENTER>' . Buttons('Submit') . '</CENTER>';
    echo '</FORM>';
    PopTable('footer');
}
if (!$_REQUEST['modfunc']) {
    if (!isset($extra)) {
        $extra = array();
    }
    Widgets('user');
    if ($_REQUEST['advanced'] == 'Y') {
        Widgets('all');
    }
    $extra['WHERE'] .= appendSQL('');
    $extra['WHERE'] .= CustomFields('where');
    echo "<FORM  name=ada_from id=ada_from onSubmit='return formcheck_ada_dates();' action=Modules.php?modname=" . strip_tags(trim($_REQUEST[modname])) . "&list_by_day=" . strip_tags(trim($_REQUEST[list_by_day])) . " method=POST>";
    $advanced_link = " <A HREF=Modules.php?modname={$_REQUEST['modname']}&modfunc=search&list_by_day={$_REQUEST['list_by_day']}&day_start={$_REQUEST['day_start']}&day_end={$_REQUEST['day_end']}&month_start={$_REQUEST['month_start']}&month_end={$_REQUEST['month_end']}&year_start={$_REQUEST['year_start']}&year_end={$_REQUEST['year_end']}>Advanced</A>";
    DrawHeaderHome('<table><tr><td>' . DateInputAY($start_date, 'start', 1) . '</td><td>&nbsp;&nbsp;-&nbsp;&nbsp;</td><td>' . DateInputAY($end_date, 'end', 2) . '</td><td> - </td><td>' . $advanced_link, ' : <INPUT type=submit value=Go  class=btn_medium></td></tr></table>');
    echo '</FORM>';
    if ($_REQUEST['list_by_day'] == 'true') {
        $cal_days = 1;
        $search_stu = 0;
        if ($_REQUEST['last'] != '' || $_REQUEST['first'] != '' || $_REQUEST['stuid'] != '' || $_REQUEST['altid'] != '') {
            $stu_q = 'SELECT GROUP_CONCAT(STUDENT_ID) as STUDENT_ID FROM students WHERE ';
            $stu_q .= $_REQUEST['last'] != '' ? ' LAST_NAME=\'' . $_REQUEST['last'] . '\' OR ' : '';
            $stu_q .= $_REQUEST['first'] != '' ? ' FIRST_NAME=\'' . $_REQUEST['first'] . '\' OR ' : '';
            $stu_q .= $_REQUEST['stuid'] != '' ? ' STUDENT_ID=\'' . $_REQUEST['stuid'] . '\' OR ' : '';
        }
    }
    $sql = mb_substr($sql, 0, -1) . " WHERE ID='{$_REQUEST['referral_id']}'";
    DBQuery($sql);
    unset($_REQUEST['values']);
    unset($_SESSION['_REQUEST_vars']['values']);
}
DrawHeader(ProgramTitle());
if ($_REQUEST['modfunc'] == 'remove' & AllowEdit()) {
    if (DeletePrompt(_('Referral'))) {
        DBQuery("DELETE FROM DISCIPLINE_REFERRALS WHERE ID='{$_REQUEST['id']}'");
        unset($_REQUEST['modfunc']);
    }
}
$categories_RET = DBGet(DBQuery("SELECT df.ID,du.TITLE FROM DISCIPLINE_FIELDS df,DISCIPLINE_FIELD_USAGE du WHERE df.DATA_TYPE!='textarea' AND du.SYEAR='" . UserSyear() . "' AND du.SCHOOL_ID='" . UserSchool() . "' AND du.DISCIPLINE_FIELD_ID=df.ID ORDER BY du.SORT_ORDER"));
Widgets('discipline');
$extra['SELECT'] = ',dr.*';
if (mb_strpos($extra['FROM'], 'DISCIPLINE_REFERRALS') === false) {
    $extra['FROM'] .= ',DISCIPLINE_REFERRALS dr ';
    $extra['WHERE'] .= ' AND dr.STUDENT_ID=ssm.STUDENT_ID AND dr.SYEAR=ssm.SYEAR AND dr.SCHOOL_ID=ssm.SCHOOL_ID ';
}
$extra['ORDER_BY'] = 'dr.ENTRY_DATE DESC,s.LAST_NAME,s.FIRST_NAME,s.MIDDLE_NAME';
$extra['columns_after'] = array('STAFF_ID' => _('Reporter'), 'ENTRY_DATE' => _('Incident Date'));
$extra['functions'] = array('STAFF_ID' => 'GetTeacher', 'ENTRY_DATE' => 'ProperDate');
foreach ($categories_RET as $category) {
    $extra['columns_after']['CATEGORY_' . $category['ID']] = $category['TITLE'];
    $extra['functions']['CATEGORY_' . $category['ID']] = '_make';
}
$extra['new'] = true;
//$extra['force_search'] = true;
$extra['singular'] = _('Referral');
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;
    }
}
                }
                unset($_REQUEST['modfunc']);
                unset($_REQUEST['food_service']);
                unset($_SESSION['_REQUEST_vars']['food_service']);
            }
        }
    } else {
        unset($_REQUEST['modfunc']);
        unset($_REQUEST['food_service']);
        unset($_SESSION['_REQUEST_vars']['food_service']);
    }
}
Widgets('fsa_discount');
Widgets('fsa_status');
Widgets('fsa_barcode');
Widgets('fsa_account_id');
$extra['SELECT'] .= ",coalesce(fssa.STATUS,'" . _('Active') . "') AS STATUS";
$extra['SELECT'] .= ",(SELECT BALANCE FROM FOOD_SERVICE_ACCOUNTS WHERE ACCOUNT_ID=fssa.ACCOUNT_ID) AS BALANCE";
if (!mb_strpos($extra['FROM'], 'fssa')) {
    $extra['FROM'] .= ",FOOD_SERVICE_STUDENT_ACCOUNTS fssa";
    $extra['WHERE'] .= " AND fssa.STUDENT_ID=s.STUDENT_ID";
}
$extra['functions'] += array('BALANCE' => 'red');
$extra['columns_after'] = array('BALANCE' => _('Balance'), 'STATUS' => _('Status'));
Search('student_id', $extra);
if (!$_REQUEST['modfunc'] && UserStudentID()) {
    $student = DBGet(DBQuery("SELECT s.STUDENT_ID,s.FIRST_NAME||' '||s.LAST_NAME AS FULL_NAME,fssa.ACCOUNT_ID,fssa.STATUS,fssa.DISCOUNT,fssa.BARCODE,(SELECT BALANCE FROM FOOD_SERVICE_ACCOUNTS WHERE ACCOUNT_ID=fssa.ACCOUNT_ID) AS BALANCE FROM STUDENTS s,FOOD_SERVICE_STUDENT_ACCOUNTS fssa WHERE s.STUDENT_ID='" . UserStudentID() . "' AND fssa.STUDENT_ID=s.STUDENT_ID"));
    $student = $student[1];
    // find other students associated with the same account
    $xstudents = DBGet(DBQuery("SELECT s.STUDENT_ID,s.FIRST_NAME||' '||s.LAST_NAME AS FULL_NAME FROM STUDENTS s,FOOD_SERVICE_STUDENT_ACCOUNTS fssa WHERE fssa.ACCOUNT_ID='" . $student['ACCOUNT_ID'] . "' AND s.STUDENT_ID=fssa.STUDENT_ID AND s.STUDENT_ID!='" . UserStudentID() . "'" . ($_REQUEST['include_inactive'] ? '' : " AND exists(SELECT '' FROM STUDENT_ENROLLMENT WHERE STUDENT_ID=s.STUDENT_ID AND SYEAR='" . UserSyear() . "' AND (START_DATE<=CURRENT_DATE AND (END_DATE IS NULL OR CURRENT_DATE<=END_DATE)))")));
    echo '<FORM action="Modules.php?modname=' . $_REQUEST[modname] . '&modfunc=update" method="POST">';
Exemple #8
0
     }
     $extra['extra_header_left'] .= '</TABLE>';
     $extra['extra_header_right'] = '<TABLE>';
     $extra['extra_header_right'] .= '<TR><TD align=right>' . _('Starting row') . '</TD><TD><SELECT name=start_row style="width:40px;">';
     for ($row = 1; $row <= $max_rows; $row++) {
         $extra['extra_header_right'] .= '<OPTION value="' . $row . '">' . $row;
     }
     $extra['extra_header_right'] .= '</SELECT></TD></TR>';
     $extra['extra_header_right'] .= '<TR><TD align=right>' . _('Starting column') . '</TD><TD><SELECT name=start_col style="width:40px;">';
     for ($col = 1; $col <= $max_cols; $col++) {
         $extra['extra_header_right'] .= '<OPTION value="' . $col . '">' . $col;
     }
     $extra['extra_header_right'] .= '</SELECT></TD></TR>';
     $extra['extra_header_right'] .= '</TABLE>';
 }
 Widgets('course');
 //Widgets('request');
 //Widgets('activity');
 //Widgets('absences');
 //Widgets('gpa');
 //Widgets('class_rank');
 //Widgets('letter_grade');
 //Widgets('eligibility');
 //$extra['force_search'] = true;
 $extra['link'] = array('FULL_NAME' => false);
 $extra['SELECT'] = ",s.STUDENT_ID AS CHECKBOX";
 $extra['functions'] = array('CHECKBOX' => '_makeChooseCheckbox');
 $extra['columns_before'] = array('CHECKBOX' => '</A><INPUT type=checkbox value=Y name=controller checked onclick="checkAll(this.form,this.form.controller.checked,\'st_arr\');"><A>');
 $extra['options']['search'] = false;
 $extra['new'] = true;
 Search('student_id', $extra);
function mySearch($type, $extra = '')
{
    global $extra;
    if ($_REQUEST['search_modfunc'] == 'search_fnc' || !$_REQUEST['search_modfunc']) {
        echo '<BR>';
        PopTable('header', 'Search');
        echo "<FORM action=Modules.php?modname=" . strip_tags(trim($_REQUEST[modname])) . "&modfunc=" . strip_tags(trim($_REQUEST[modfunc])) . "&search_modfunc=list&next_modname=" . strip_tags(trim($_REQUEST[next_modname])) . " method=POST>";
        echo '<TABLE border=0>';
        $RET = DBGet(DBQuery('SELECT s.STAFF_ID,CONCAT(s.LAST_NAME,\'' . ',' . '\',s.FIRST_NAME) AS FULL_NAME FROM staff s,staff_school_relationship ssr WHERE s.STAFF_ID=ssr.STAFF_ID AND s.PROFILE=\'' . 'teacher' . '\' AND position(\'' . UserSchool() . '\' IN ssr.SCHOOL_ID)>0 AND ssr.SYEAR=\'' . UserSyear() . '\' ORDER BY FULL_NAME'));
        echo '<TR><TD align=right width=120>Teacher</TD><TD>';
        echo "<SELECT name=teacher_id style='max-width:250;'><OPTION value=''>N/A</OPTION>";
        foreach ($RET as $teacher) {
            echo "<OPTION value={$teacher['STAFF_ID']}>{$teacher['FULL_NAME']}</OPTION>";
        }
        echo '</SELECT>';
        echo '</TD></TR>';
        $RET = DBGet(DBQuery('SELECT SUBJECT_ID,TITLE FROM course_subjects WHERE SCHOOL_ID=\'' . UserSchool() . '\' AND SYEAR=\'' . UserSyear() . '\' ORDER BY TITLE'));
        echo '<TR><TD align=right width=120>Subject</TD><TD>';
        echo "<SELECT name=subject_id style='max-width:250;'><OPTION value=''>N/A</OPTION>";
        foreach ($RET as $subject) {
            echo "<OPTION value={$subject['SUBJECT_ID']}>{$subject['TITLE']}</OPTION>";
        }
        echo '</SELECT>';
        $RET = DBGet(DBQuery('SELECT PERIOD_ID,TITLE FROM school_periods WHERE SYEAR=\'' . UserSyear() . '\' AND SCHOOL_ID=\'' . UserSchool() . '\' ORDER BY SORT_ORDER'));
        echo '<TR><TD align=right width=120>Period</TD><TD>';
        echo "<SELECT name=period_id style='max-width:250;'><OPTION value=''>N/A</OPTION>";
        foreach ($RET as $period) {
            echo "<OPTION value={$period['PERIOD_ID']}>{$period['TITLE']}</OPTION>";
        }
        echo '</SELECT>';
        echo '</TD></TR>';
        Widgets('course');
        echo $extra['search'];
        echo '<TR><TD colspan=2 align=center>';
        echo '<BR>';
        echo Buttons('Submit', 'Reset');
        echo '</TD></TR>';
        echo '</TABLE>';
        echo '</FORM>';
        PopTable('footer');
    } else {
        DrawHeader('', $extra['header_right']);
        DrawHeader($extra['extra_header_left'], $extra['extra_header_right']);
        if (User('PROFILE') == 'admin') {
            if ($_REQUEST['teacher_id']) {
                $where .= ' AND cp.TEACHER_ID=\'' . $_REQUEST[teacher_id] . '\'';
            }
            if ($_REQUEST['first']) {
                $where .= ' AND UPPER(s.FIRST_NAME) LIKE \'' . strtoupper($_REQUEST['first']) . '%' . '\'';
            }
            if ($_REQUEST['w_course_period_id']) {
                if ($_REQUEST['w_course_period_id_which'] == 'course') {
                    $where .= ' AND cp.COURSE_ID=(SELECT COURSE_ID FROM course_periods WHERE COURSE_PERIOD_ID=\'' . $_REQUEST['w_course_period_id'] . '\')';
                } else {
                    $where .= ' AND cp.COURSE_PERIOD_ID=\'' . $_REQUEST['w_course_period_id'] . '\'';
                }
            }
            if ($_REQUEST['subject_id']) {
                $from .= ',courses c';
                $where .= ' AND c.COURSE_ID=cp.COURSE_ID AND c.SUBJECT_ID=\'' . $_REQUEST['subject_id'] . '\'';
            }
            if ($_REQUEST['period_id']) {
                $where .= " AND cpv.PERIOD_ID='" . $_REQUEST['period_id'] . "'";
            }
            $sql = 'SELECT cp.COURSE_PERIOD_ID,cp.TITLE,sp.ATTENDANCE FROM course_periods cp,course_period_var cpv,school_periods sp' . $from . ' WHERE cp.SCHOOL_ID=\'' . UserSchool() . '\' AND cp.COURSE_PERIOD_ID=cpv.COURSE_PERIOD_ID AND cp.SYEAR=\'' . UserSyear() . '\' AND sp.PERIOD_ID=cpv.PERIOD_ID' . $where . '';
        } elseif (User('PROFILE') == 'teacher') {
            $sql = 'SELECT cp.COURSE_PERIOD_ID,cp.TITLE,sp.ATTENDANCE FROM course_periods cp,course_period_var cpv,school_periods sp WHERE cp.SCHOOL_ID=\'' . UserSchool() . '\' AND cp.SYEAR=\'' . UserSyear() . '\' AND cp.TEACHER_ID=\'' . User('STAFF_ID') . '\' AND sp.PERIOD_ID=cpv.PERIOD_ID AND cp.COURSE_PERIOD_ID=cpv.COURSE_PERIOD_ID';
        } else {
            $sql = 'SELECT cp.COURSE_PERIOD_ID,cp.TITLE,sp.ATTENDANCE FROM course_periods cp,course_period_var cpv,school_periods sp,schedule ss WHERE cp.SCHOOL_ID=\'' . UserSchool() . '\' AND cp.COURSE_PERIOD_ID=ss.COURSE_PERIOD_ID AND ss.SYEAR=\'' . UserSyear() . '\' AND ss.STUDENT_ID=\'' . UserStudentID() . '\' AND (CURRENT_DATE>=ss.START_DATE AND (ss.END_DATE IS NULL OR CURRENT_DATE<=ss.END_DATE)) AND sp.PERIOD_ID=cpv.PERIOD_ID AND cp.COURSE_PERIOD_ID=cpv.COURSE_PERIOD_ID';
        }
        $sql .= ' GROUP BY cp.COURSE_PERIOD_ID ORDER BY sp.PERIOD_ID';
        $course_periods_RET = DBGet(DBQuery($sql), array('COURSE_PERIOD_ID' => '_makeChooseCheckbox'));
        $_SESSION['count_course_periods'] = count($course_periods_RET);
        $LO_columns = array('COURSE_PERIOD_ID' => '</A><INPUT type=checkbox value=Y name=controller onclick="checkAll(this.form,this.form.controller.checked,\'cp_arr\');"><A>', 'TITLE' => 'Course Period');
        ListOutput($course_periods_RET, $LO_columns, 'Course Period', 'Course Periods');
    }
}
function mySearch($type, $extra = '')
{
    global $extra;
    if ($_REQUEST['search_modfunc'] == 'search_fnc' || !$_REQUEST['search_modfunc']) {
        echo '<BR>';
        PopTable('header', 'Search');
        echo "<FORM action=Modules.php?modname={$_REQUEST['modname']}&modfunc={$_REQUEST['modfunc']}&search_modfunc=list&next_modname={$_REQUEST['next_modname']} method=POST>";
        echo '<TABLE border=0>';
        $RET = DBGet(DBQuery("SELECT STAFF_ID,CONCAT(LAST_NAME,LAST_NAME,', ',FIRST_NAME) AS FULL_NAME FROM STAFF WHERE PROFILE='teacher' AND position('," . UserSchool() . ",' IN SCHOOLS)>0 AND SYEAR='" . UserSyear() . "' ORDER BY FULL_NAME"));
        echo '<TR><TD align=right width=120>Teacher</TD><TD>';
        echo "<SELECT name=teacher_id style='max-width:250;'><OPTION value=''>N/A</OPTION>";
        foreach ($RET as $teacher) {
            echo "<OPTION value={$teacher['STAFF_ID']}>{$teacher['FULL_NAME']}</OPTION>";
        }
        echo '</SELECT>';
        echo '</TD></TR>';
        $RET = DBGet(DBQuery("SELECT SUBJECT_ID,TITLE FROM COURSE_SUBJECTS WHERE SCHOOL_ID='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "' ORDER BY TITLE"));
        echo '<TR><TD align=right width=120>Subject</TD><TD>';
        echo "<SELECT name=subject_id style='max-width:250;'><OPTION value=''>N/A</OPTION>";
        foreach ($RET as $subject) {
            echo "<OPTION value={$subject['SUBJECT_ID']}>{$subject['TITLE']}</OPTION>";
        }
        echo '</SELECT>';
        $RET = DBGet(DBQuery("SELECT PERIOD_ID,TITLE FROM SCHOOL_PERIODS WHERE SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "' ORDER BY SORT_ORDER"));
        echo '<TR><TD align=right width=120>Period</TD><TD>';
        echo "<SELECT name=period_id style='max-width:250;'><OPTION value=''>N/A</OPTION>";
        foreach ($RET as $period) {
            echo "<OPTION value={$period['PERIOD_ID']}>{$period['TITLE']}</OPTION>";
        }
        echo '</SELECT>';
        echo '</TD></TR>';
        Widgets('course');
        echo $extra['search'];
        echo '<TR><TD colspan=2 align=center>';
        echo '<BR>';
        echo Buttons('Submit', 'Reset');
        echo '</TD></TR>';
        echo '</TABLE>';
        echo '</FORM>';
        PopTable('footer');
    } else {
        DrawHeader('', $extra['header_right']);
        DrawHeader($extra['extra_header_left'], $extra['extra_header_right']);
        if (User('PROFILE') == 'admin') {
            if ($_REQUEST['teacher_id']) {
                $where .= " AND cp.TEACHER_ID='{$_REQUEST['teacher_id']}'";
            }
            if ($_REQUEST['first']) {
                $where .= " AND UPPER(s.FIRST_NAME) LIKE '" . strtoupper($_REQUEST['first']) . "%'";
            }
            if ($_REQUEST['w_course_period_id']) {
                if ($_REQUEST['w_course_period_id_which'] == 'course') {
                    $where .= " AND cp.COURSE_ID=(SELECT COURSE_ID FROM COURSE_PERIODS WHERE COURSE_PERIOD_ID='" . $_REQUEST['w_course_period_id'] . "')";
                } else {
                    $where .= " AND cp.COURSE_PERIOD_ID='" . $_REQUEST['w_course_period_id'] . "'";
                }
            }
            if ($_REQUEST['subject_id']) {
                $from .= ",COURSES c";
                $where .= " AND c.COURSE_ID=cp.COURSE_ID AND c.SUBJECT_ID='" . $_REQUEST['subject_id'] . "'";
            }
            if ($_REQUEST['period_id']) {
                $where .= " AND cp.PERIOD_ID='" . $_REQUEST['period_id'] . "'";
            }
            $sql = "SELECT cp.COURSE_PERIOD_ID,cp.TITLE,sp.ATTENDANCE FROM COURSE_PERIODS cp,SCHOOL_PERIODS sp{$from} WHERE cp.SCHOOL_ID='" . UserSchool() . "' AND cp.SYEAR='" . UserSyear() . "' AND sp.PERIOD_ID=cp.PERIOD_ID{$where}";
        } elseif (User('PROFILE') == 'teacher') {
            $sql = "SELECT cp.COURSE_PERIOD_ID,cp.TITLE,sp.ATTENDANCE FROM COURSE_PERIODS cp,SCHOOL_PERIODS sp WHERE cp.SCHOOL_ID='" . UserSchool() . "' AND cp.SYEAR='" . UserSyear() . "' AND cp.TEACHER_ID='" . User('STAFF_ID') . "' AND sp.PERIOD_ID=cp.PERIOD_ID";
        } else {
            $sql = "SELECT cp.COURSE_PERIOD_ID,cp.TITLE,sp.ATTENDANCE FROM COURSE_PERIODS cp,SCHOOL_PERIODS sp,SCHEDULE ss WHERE cp.SCHOOL_ID='" . UserSchool() . "' AND cp.COURSE_PERIOD_ID=ss.COURSE_PERIOD_ID AND ss.SYEAR='" . UserSyear() . "' AND ss.STUDENT_ID='" . UserStudentID() . "' AND (CURRENT_DATE>=ss.START_DATE AND (ss.END_DATE IS NULL OR CURRENT_DATE<=ss.END_DATE)) AND sp.PERIOD_ID=cp.PERIOD_ID";
        }
        $sql .= ' ORDER BY sp.PERIOD_ID';
        $course_periods_RET = DBGet(DBQuery($sql), array('COURSE_PERIOD_ID' => '_makeChooseCheckbox'));
        $LO_columns = array('COURSE_PERIOD_ID' => '</A><INPUT type=checkbox value=Y name=controller onclick="checkAll(this.form,this.form.controller.checked,\'cp_arr\');"><A>', 'TITLE' => 'Course Period');
        ListOutput($course_periods_RET, $LO_columns, 'Course Period', 'Course Periods');
    }
}
Exemple #11
0
<?php

/**
* @file $Id: Statements.php 422 2007-02-10 22:08:22Z focus-sis $
* @package Focus/SIS
* @copyright Copyright (C) 2006 Andrew Schmadeke. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
* Focus/SIS is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.txt for copyright notices and details.
*/
Widgets('all');
Widgets('mailing_labels');
Widgets('document_template');
$extra['force_search'] = true;
if (!$_REQUEST['search_modfunc'] || $_REQUEST['search_modfunc'] == 'search' || $_FOCUS['modules_search']) {
    DrawHeader(ProgramTitle());
    $extra['new'] = true;
    $extra['action'] .= "&_FOCUS_PDF=true";
    Search('student_id', $extra);
} else {
    // For the Student Fees / Student Payments programs
    $_REQUEST['print_statements'] = true;
    if ($_REQUEST['mailing_labels'] == 'Y') {
        $extra['group'][] = 'ADDRESS_ID';
    }
    $RET = GetStuList($extra);
    if (count($RET)) {
        $handle = PDFStart();
     echo '<FORM action="Modules.php?modname=' . $_REQUEST['modname'] . '&modfunc=save&_ROSARIO_PDF=true" method="POST">';
     //DrawHeader('',SubmitButton('Create Reminders for Selected Students'));
     //modif Francois: add translation
     $extra['header_right'] = SubmitButton(_('Create Reminders for Selected Students'));
     $extra['extra_header_left'] = '<TABLE><TR>';
     $extra['extra_header_left'] .= '<TD style="text-align:right"><label>' . _('Estimate for year end') . '&nbsp;<INPUT type="checkbox" name="year_end" value="Y" /></label></TD>';
     $extra['extra_header_left'] .= '</TR></TABLE>';
 }
 $extra['link'] = array('FULL_NAME' => false);
 $extra['SELECT'] = ",s.STUDENT_ID AS CHECKBOX";
 $extra['functions'] = array('CHECKBOX' => '_makeChooseCheckbox');
 $extra['columns_before'] = array('CHECKBOX' => '</A><INPUT type="checkbox" value="Y" checked name="controller" onclick="checkAll(this.form,this.form.controller.checked,\'st_arr\');"><A>');
 $extra['new'] = true;
 $extra['options']['search'] = false;
 Widgets('fsa_balance_warning');
 Widgets('fsa_status');
 $extra['SELECT'] .= ',coalesce(fssa.STATUS,\'Active\') AS STATUS,fsa.BALANCE';
 $extra['SELECT'] .= ',(SELECT \'Y\' WHERE fsa.BALANCE < \'' . $warning . '\' AND fsa.BALANCE >= 0) AS WARNING';
 $extra['SELECT'] .= ',(SELECT \'Y\' WHERE fsa.BALANCE < 0 AND fsa.BALANCE >= \'' . $minimum . '\') AS NEGATIVE';
 $extra['SELECT'] .= ',(SELECT \'Y\' WHERE fsa.BALANCE < \'' . $minimum . '\') AS MINIMUM';
 if (!mb_strpos($extra['FROM'], 'fssa')) {
     $extra['FROM'] .= ',FOOD_SERVICE_STUDENT_ACCOUNTS fssa';
     $extra['WHERE'] .= ' AND fssa.STUDENT_ID=s.STUDENT_ID';
 }
 if (!mb_strpos($extra['FROM'], 'fsa')) {
     $extra['FROM'] .= ',FOOD_SERVICE_ACCOUNTS fsa';
     $extra['WHERE'] .= ' AND fsa.ACCOUNT_ID=fssa.ACCOUNT_ID';
 }
 $extra['functions'] += array('BALANCE' => 'red', 'WARNING' => 'x', 'NEGATIVE' => 'x', 'MINIMUM' => 'x');
 $extra['columns_after'] = array('BALANCE' => _('Balance'), 'STATUS' => _('Status'), 'WARNING' => _('Warning') . '<BR />&lt; ' . $warning, 'NEGATIVE' => _('Negative'), 'MINIMUM' => _('Minimum') . '<BR />' . $minimum);
 Search('student_id', $extra);
Exemple #13
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;
    }
}
Exemple #14
0
    if ($request_exists) {
        DrawHeaderHome('<IMG SRC=assets/warning_button.gif>' . $request_clash . ' already have unscheduled requests');
    }
}
if (!$_REQUEST['modfunc']) {
    if ($_REQUEST['search_modfunc'] != 'list') {
        unset($_SESSION['MassSchedule.php']);
    }
    $extra['link'] = array('FULL_NAME' => false);
    $extra['SELECT'] = ",CAST(NULL AS CHAR(1)) AS CHECKBOX";
    $extra['functions'] = array('CHECKBOX' => '_makeChooseCheckbox');
    $extra['columns_before'] = array('CHECKBOX' => '</A><INPUT type=checkbox value=Y name=controller onclick="checkAll(this.form,this.form.controller.checked,\'student\');"><A>');
    $extra['new'] = true;
    Widgets('course');
    Widgets('request');
    Widgets('activity');
    Search('student_id', $extra);
    if ($_REQUEST['search_modfunc'] == 'list') {
        echo '<BR><CENTER>' . SubmitButton('Add Course to Selected Students', '', 'class=btn_xlarge onclick=\'formload_ajax("sav");\'') . '</CENTER>';
        echo "</FORM>";
    }
}
if ($_REQUEST['modfunc'] == 'choose_course') {
    //	if($_REQUEST['course_id'])
    //	{
    //		$weights_RET = DBGet(DBQuery("SELECT COURSE_WEIGHT,GPA_MULTIPLIER FROM COURSE_WEIGHTS WHERE COURSE_ID='$_REQUEST[course_id]'"));
    //		if(count($weights_RET)==1)
    //			$_REQUEST['course_weight'] = $weights_RET[1]['COURSE_WEIGHT'];
    //	}
    if (!$_REQUEST['course_period_id']) {
        include 'modules/Scheduling/CoursesforWindow.php';
            echo '</TABLE>';
            echo '</FORM>';
            PopTable('footer');
            break;
    }
} else {
    if (!$_REQUEST['next_modname']) {
        $_REQUEST['next_modname'] = 'Students/Student.php';
    }
    if (User('PROFILE') == 'admin' || User('PROFILE') == 'teacher') {
        if (!isset($extra)) {
            $extra = array();
        }
        Widgets('user', $extra);
        if ($_REQUEST['advanced'] == 'Y') {
            Widgets('all', $extra);
        }
    }
    if (!$extra['NoSearchTerms']) {
        if ($_REQUEST['_search_all_schools'] == 'Y') {
            $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . _('Search All Schools') . '</b></span><BR />';
        }
        if ($_REQUEST['include_inactive'] == 'Y') {
            $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . _('Include Inactive Students') . '</b></span><BR />';
        }
    }
    if ($_REQUEST['address_group']) {
        $extra['SELECT'] .= ",coalesce((SELECT ADDRESS_ID FROM STUDENTS_JOIN_ADDRESS WHERE STUDENT_ID=ssm.STUDENT_ID AND RESIDENCE='Y' LIMIT 1),-ssm.STUDENT_ID) AS FAMILY_ID";
        $extra['group'] = $extra['LO_group'] = array('FAMILY_ID');
    }
    $extra['WHERE'] .= appendSQL('', array('NoSearchTerms' => $extra['NoSearchTerms']));
Exemple #16
0
#  See license.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#***************************************************************************************
include '../../RedirectModulesInc.php';
DrawBC("Extracurricular > " . ProgramTitle());
Widgets('activity');
Widgets('course');
Widgets('eligibility');
Search('student_id', $extra);
if ($_REQUEST['modfunc'] == 'add' || $_REQUEST['student_id']) {
    if ($_REQUEST['student_id']) {
        $RET = DBGet(DBQuery('SELECT FIRST_NAME,LAST_NAME,MIDDLE_NAME,NAME_SUFFIX FROM students WHERE STUDENT_ID=\'' . $_REQUEST['student_id'] . '\''));
    } else {
        $RET = DBGet(DBQuery('SELECT FIRST_NAME,LAST_NAME,MIDDLE_NAME,NAME_SUFFIX FROM students WHERE STUDENT_ID=\'' . UserStudentID() . '\''));
    }
    $count_student_RET = DBGet(DBQuery('SELECT COUNT(*) AS NUM FROM students'));
    if ($count_student_RET[1]['NUM'] > 1) {
        DrawHeaderHome('Selected Student: ' . $RET[1]['FIRST_NAME'] . '&nbsp;' . ($RET[1]['MIDDLE_NAME'] ? $RET[1]['MIDDLE_NAME'] . ' ' : '') . $RET[1]['LAST_NAME'] . '&nbsp;' . ' (<A HREF=Side.php?student_id=new&modcat=' . clean_param($_REQUEST['modcat'], PARAM_NOTAGS) . '><font color=red>Search Again</font></A>) | <A HREF=Modules.php?modname=' . clean_param($_REQUEST['modname'], PARAM_NOTAGS) . '&search_modfunc=list&next_modname=Students/Student.php&ajax=true&bottom_back=true&return_session=true target=body>Back to Student List</A>');
    } else {
        if ($count_student_RET[1]['NUM'] == 1) {
            DrawHeaderHome('Selected Student: ' . $RET[1]['FIRST_NAME'] . '&nbsp;' . ($RET[1]['MIDDLE_NAME'] ? $RET[1]['MIDDLE_NAME'] . ' ' : '') . $RET[1]['LAST_NAME'] . '&nbsp;' . ' (<A HREF=Side.php?student_id=new&modcat=' . clean_param($_REQUEST['modcat'], PARAM_NOTAGS) . '><font color=red>Search Again</font></A>) ');
        }
    }
<?php

Widgets('fsa_status_active');
Widgets('fsa_barcode');
Search('student_id', $extra);
if ($_REQUEST['modfunc'] == 'submit') {
    if ($_REQUEST['submit']['cancel']) {
        //modif Francois: add translation
        if (DeletePromptX(_('Sale'), _('Cancel'))) {
            unset($_SESSION['FSA_sale']);
        }
    } elseif ($_REQUEST['submit']['save']) {
        if (count($_SESSION['FSA_sale'])) {
            $student = DBGet(DBQuery("SELECT ACCOUNT_ID,DISCOUNT FROM FOOD_SERVICE_STUDENT_ACCOUNTS WHERE STUDENT_ID='" . UserStudentID() . "'"));
            $student = $student[1];
            $items_RET = DBGet(DBQuery("SELECT DESCRIPTION,SHORT_NAME,PRICE,PRICE_REDUCED,PRICE_FREE FROM FOOD_SERVICE_ITEMS WHERE SCHOOL_ID='" . UserSchool() . "'"), array(), array('SHORT_NAME'));
            // get next transaction id
            $id = DBGet(DBQuery("SELECT " . db_seq_nextval('FOOD_SERVICE_TRANSACTIONS_SEQ') . " AS SEQ_ID " . FROM_DUAL));
            $id = $id[1]['SEQ_ID'];
            $item_id = 0;
            foreach ($_SESSION['FSA_sale'] as $item_sn) {
                // determine price based on discount
                $price = $items_RET[$item_sn][1]['PRICE'];
                $discount = $student['DISCOUNT'];
                if ($student['DISCOUNT'] == 'Reduced') {
                    if ($items_RET[$item_sn][1]['PRICE_REDUCED'] != '') {
                        $price = $items_RET[$item_sn][1]['PRICE_REDUCED'];
                    } else {
                        $discount = '';
                    }
                } elseif ($student['DISCOUNT'] == 'Free') {
#  This program is released under the terms of the GNU General Public License as
#  published by the Free Software Foundation, version 2 of the License.
#  See license.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#***************************************************************************************
include '../../Redirect_modules.php';
DrawHeader(ProgramTitle());
Widgets('request');
if (!UserStudentID()) {
    echo '<BR>';
}
Search('student_id', $extra);
if (!$_REQUEST['modfunc'] && UserStudentID()) {
    $_REQUEST['modfunc'] = 'choose';
}
if ($_REQUEST['modfunc'] == 'verify') {
    $QI = DBQuery("SELECT TITLE,COURSE_ID,SUBJECT_ID FROM COURSES WHERE SCHOOL_ID='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "'");
    $courses_RET = DBGet($QI, array(), array('COURSE_ID'));
    //$QI = DBQuery("SELECT COURSE_WEIGHT,COURSE_ID FROM COURSE_WEIGHTS WHERE SCHOOL_ID='".UserSchool()."' AND SYEAR='".UserSyear()."'");
    //$weights_RET = DBGet($QI,array(),array('COURSE_ID','COURSE_WEIGHT'));
    DBQuery("DELETE FROM SCHEDULE_REQUESTS WHERE STUDENT_ID='" . UserStudentID() . "' AND SYEAR='" . UserSyear() . "'");
    foreach ($_REQUEST['courses'] as $subject => $courses) {
        $courses_count = count($courses);
function mySearch($type, $extra = '')
{
    global $extra;
    if ($_REQUEST['search_modfunc'] == 'search_fnc' || !$_REQUEST['search_modfunc']) {
        $_SESSION['Search_PHP_SELF'] = PreparePHP_SELF($_SESSION['_REQUEST_vars'], array('bottom_back'));
        if ($_SESSION['Back_PHP_SELF'] != 'course') {
            $_SESSION['Back_PHP_SELF'] = 'course';
            unset($_SESSION['List_PHP_SELF']);
        }
        echo '<script type="text/javascript">parent.help.location.reload();</script>';
        echo '<BR />';
        PopTable('header', _('Find a Course'));
        echo '<FORM action="Modules.php?modname=' . $_REQUEST['modname'] . '&modfunc=' . $_REQUEST['modfunc'] . '&search_modfunc=list&next_modname=' . $_REQUEST['next_modname'] . '" method="POST">';
        echo '<TABLE>';
        $RET = DBGet(DBQuery("SELECT STAFF_ID,LAST_NAME||', '||FIRST_NAME AS FULL_NAME FROM STAFF WHERE PROFILE='teacher' AND (SCHOOLS IS NULL OR position('," . UserSchool() . ",' IN SCHOOLS)>0) AND SYEAR='" . UserSyear() . "' ORDER BY FULL_NAME"));
        echo '<TR><TD style="text-align:right; width:120px:">' . _('Teacher') . '</TD><TD>';
        echo '<SELECT name="teacher_id" style="max-width:250;"><OPTION value="">' . _('N/A') . '</OPTION>';
        foreach ($RET as $teacher) {
            echo '<OPTION value="' . $teacher['STAFF_ID'] . '">' . $teacher['FULL_NAME'] . '</OPTION>';
        }
        echo '</SELECT>';
        echo '</TD></TR>';
        $RET = DBGet(DBQuery("SELECT SUBJECT_ID,TITLE FROM COURSE_SUBJECTS WHERE SCHOOL_ID='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "' ORDER BY TITLE"));
        echo '<TR><TD style="text-align:right; width:120px:">' . _('Subject') . '</TD><TD>';
        echo '<SELECT name="subject_id" style="max-width:250;"><OPTION value="">' . _('N/A') . '</OPTION>';
        foreach ($RET as $subject) {
            echo '<OPTION value="' . $subject['SUBJECT_ID'] . '">' . $subject['TITLE'] . '</OPTION>';
        }
        echo '</SELECT>';
        $RET = DBGet(DBQuery("SELECT PERIOD_ID,TITLE FROM SCHOOL_PERIODS WHERE SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "' ORDER BY SORT_ORDER"));
        echo '<TR><TD style="text-align:right; width:120px:">' . _('Period') . '</TD><TD>';
        echo "<SELECT name=period_id style='max-width:250;'><OPTION value=''>" . _('N/A') . "</OPTION>";
        foreach ($RET as $period) {
            echo "<OPTION value={$period['PERIOD_ID']}>{$period['TITLE']}</OPTION>";
        }
        echo '</SELECT>';
        echo '</TD></TR>';
        Widgets('course');
        echo $extra['search'];
        echo '<TR><TD colspan="2" class="center">';
        echo '<BR />';
        echo Buttons(_('Submit'), _('Reset'));
        echo '</TD></TR>';
        echo '</TABLE>';
        echo '</FORM>';
        PopTable('footer');
    } else {
        DrawHeader('', $extra['header_right']);
        DrawHeader($extra['extra_header_left'], $extra['extra_header_right']);
        if (User('PROFILE') == 'admin') {
            if ($_REQUEST['teacher_id']) {
                $where .= " AND cp.TEACHER_ID='{$_REQUEST['teacher_id']}'";
            }
            if ($_REQUEST['first']) {
                $where .= " AND UPPER(s.FIRST_NAME) LIKE '" . mb_strtoupper($_REQUEST['first']) . "%'";
            }
            if ($_REQUEST['w_course_period_id']) {
                if ($_REQUEST['w_course_period_id_which'] == 'course') {
                    $where .= " AND cp.COURSE_ID=(SELECT COURSE_ID FROM COURSE_PERIODS WHERE COURSE_PERIOD_ID='" . $_REQUEST['w_course_period_id'] . "')";
                } else {
                    $where .= " AND cp.COURSE_PERIOD_ID='" . $_REQUEST['w_course_period_id'] . "'";
                }
            }
            if ($_REQUEST['subject_id']) {
                $from .= ",COURSES c";
                $where .= " AND c.COURSE_ID=cp.COURSE_ID AND c.SUBJECT_ID='" . $_REQUEST['subject_id'] . "'";
            }
            //modif Francois: multiple school periods for a course period
            if ($_REQUEST['period_id']) {
                //$where .= " AND cp.PERIOD_ID='".$_REQUEST['period_id']."'";
                $where .= " AND cpsp.PERIOD_ID='" . $_REQUEST['period_id'] . "' AND cp.COURSE_PERIOD_ID=cpsp.COURSE_PERIOD_ID";
                $from .= ",COURSE_PERIOD_SCHOOL_PERIODS cpsp";
            }
            //$sql = "SELECT cp.COURSE_PERIOD_ID,cp.TITLE,sp.ATTENDANCE FROM COURSE_PERIODS cp,SCHOOL_PERIODS sp$from WHERE cp.SCHOOL_ID='".UserSchool()."' AND cp.SYEAR='".UserSyear()."' AND sp.PERIOD_ID=cp.PERIOD_ID$where";
            $sql = "SELECT cp.COURSE_PERIOD_ID,cp.TITLE FROM COURSE_PERIODS cp{$from} WHERE cp.SCHOOL_ID='" . UserSchool() . "' AND cp.SYEAR='" . UserSyear() . "'{$where}";
        } elseif (User('PROFILE') == 'teacher') {
            //modif Francois: multiple school periods for a course period
            //$sql = "SELECT cp.COURSE_PERIOD_ID,cp.TITLE,sp.ATTENDANCE FROM COURSE_PERIODS cp,SCHOOL_PERIODS sp WHERE cp.SCHOOL_ID='".UserSchool()."' AND cp.SYEAR='".UserSyear()."' AND cp.TEACHER_ID='".User('STAFF_ID')."' AND sp.PERIOD_ID=cp.PERIOD_ID";
            $sql = "SELECT cp.COURSE_PERIOD_ID,cp.TITLE FROM COURSE_PERIODS cp WHERE cp.SCHOOL_ID='" . UserSchool() . "' AND cp.SYEAR='" . UserSyear() . "' AND cp.TEACHER_ID='" . User('STAFF_ID') . "'";
        } else {
            //modif Francois: multiple school periods for a course period
            //$sql = "SELECT cp.COURSE_PERIOD_ID,cp.TITLE,sp.ATTENDANCE FROM COURSE_PERIODS cp,SCHOOL_PERIODS sp,SCHEDULE ss WHERE cp.SCHOOL_ID='".UserSchool()."' AND cp.COURSE_PERIOD_ID=ss.COURSE_PERIOD_ID AND ss.SYEAR='".UserSyear()."' AND ss.STUDENT_ID='".UserStudentID()."' AND (CURRENT_DATE>=ss.START_DATE AND (ss.END_DATE IS NULL OR CURRENT_DATE<=ss.END_DATE)) AND sp.PERIOD_ID=cp.PERIOD_ID";
            $sql = "SELECT cp.COURSE_PERIOD_ID,cp.TITLE FROM COURSE_PERIODS cp,SCHEDULE ss WHERE cp.SCHOOL_ID='" . UserSchool() . "' AND cp.COURSE_PERIOD_ID=ss.COURSE_PERIOD_ID AND ss.SYEAR='" . UserSyear() . "' AND ss.STUDENT_ID='" . UserStudentID() . "' AND (CURRENT_DATE>=ss.START_DATE AND (ss.END_DATE IS NULL OR CURRENT_DATE<=ss.END_DATE))";
        }
        //$sql .= ' ORDER BY sp.PERIOD_ID';
        $course_periods_RET = DBGet(DBQuery($sql), array('COURSE_PERIOD_ID' => '_makeChooseCheckbox'));
        $LO_columns = array('COURSE_PERIOD_ID' => '</A><INPUT type="checkbox" value="Y" name="controller" onclick="checkAll(this.form,this.form.controller.checked,\'cp_arr\');" checked /><A>', 'TITLE' => _('Course Period'));
        if (!$_REQUEST['LO_save'] && !$extra['suppress_save']) {
            $_SESSION['List_PHP_SELF'] = PreparePHP_SELF($_SESSION['_REQUEST_vars'], array('bottom_back'));
            if ($_SESSION['Back_PHP_SELF'] != 'course') {
                $_SESSION['Back_PHP_SELF'] = 'course';
                unset($_SESSION['Search_PHP_SELF']);
            }
            echo '<script type="text/javascript">parent.help.location.reload();</script>';
        }
        echo '<INPUT type="hidden" name="relation">';
        ListOutput($course_periods_RET, $LO_columns, 'Course Period', 'Course Periods');
    }
}