Example #1
0
function ParseMLArray($array, $keys)
{
    foreach ($array as $k => $v) {
        if (is_array($v)) {
            $array[$k] = ParseMLArray($v, $keys);
        } else {
            if (!is_array($keys)) {
                $keys = array($keys);
            }
            foreach ($keys as $key) {
                if ($k == $key) {
                    $array[$k] = ParseMLField($v);
                }
            }
        }
    }
    return $array;
}
    echo '</TD>';
    // FIELDS
    if ($_REQUEST['category_id'] && $_REQUEST['category_id'] != 'new' && count($categories_RET)) {
        $sql = "SELECT ID,TITLE,TYPE,SORT_ORDER FROM CUSTOM_FIELDS WHERE CATEGORY_ID='" . $_REQUEST['category_id'] . "' ORDER BY SORT_ORDER,TITLE";
        $fields_RET = DBGet(DBQuery($sql), array('TYPE' => '_makeType'));
        if (count($fields_RET)) {
            if ($_REQUEST['id'] && $_REQUEST['id'] != 'new') {
                foreach ($fields_RET as $key => $value) {
                    if ($value['ID'] == $_REQUEST['id']) {
                        $fields_RET[$key]['row_color'] = Preferences('HIGHLIGHT');
                    }
                }
            }
        }
        echo '<TD class="valign-top">';
        $columns = array('TITLE' => _('Student Field'), 'SORT_ORDER' => _('Order'), 'TYPE' => _('Data Type'));
        $link = array();
        $link['TITLE']['link'] = "Modules.php?modname={$_REQUEST['modname']}&category_id={$_REQUEST['category_id']}";
        $link['TITLE']['variables'] = array('id' => 'ID');
        $link['add']['link'] = "Modules.php?modname={$_REQUEST['modname']}&category_id={$_REQUEST['category_id']}&id=new";
        $fields_RET = ParseMLArray($fields_RET, 'TITLE');
        ListOutput($fields_RET, $columns, 'Student Field', 'Student Fields', $link, array(), $LO_options);
        echo '</TD>';
    }
    echo '</TR></TABLE>';
}
function _makeType($value, $name)
{
    $options = array('radio' => _('Checkbox'), 'text' => _('Text'), 'autos' => _('Auto Pull-Down'), 'edits' => _('Edit Pull-Down'), 'select' => _('Pull-Down'), 'codeds' => _('Coded Pull-Down'), 'exports' => _('Export Pull-Down'), 'date' => _('Date'), 'numeric' => _('Number'), 'textarea' => _('Long Text'), 'multiple' => _('Select Multiple'));
    return $options[$value];
}
Example #3
0
function Search($type, $extra = null)
{
    global $_ROSARIO;
    switch ($type) {
        case 'student_id':
            if ($_REQUEST['bottom_back']) {
                unset($_SESSION['student_id']);
                echo '<script type="text/javascript">parent.side.location="' . $_SESSION['Side_PHP_SELF'] . '?modcat="+parent.side.document.forms[0].modcat.value;</script>';
            }
            if ($_SESSION['unset_student']) {
                unset($_REQUEST['student_id']);
                unset($_SESSION['unset_student']);
            }
            if ($_REQUEST['student_id']) {
                if ($_REQUEST['student_id'] != 'new') {
                    $_SESSION['student_id'] = $_REQUEST['student_id'];
                    if ($_REQUEST['school_id']) {
                        $_SESSION['UserSchool'] = $_REQUEST['school_id'];
                    }
                } else {
                    unset($_SESSION['student_id']);
                }
                if (!isset($_REQUEST['_ROSARIO_PDF'])) {
                    echo '<script type="text/javascript">parent.side.location="' . $_SESSION['Side_PHP_SELF'] . '?modcat="+parent.side.document.forms[0].modcat.value;</script>';
                }
            } elseif (!UserStudentID() || $extra['new'] == true) {
                if (UserStudentID()) {
                    //modif Francois: fix bug no student found when student/parent logged in
                    if (User('PROFILE') !== 'student' && User('PROFILE') !== 'parent') {
                        unset($_SESSION['student_id']);
                    }
                    echo '<script type="text/javascript">parent.side.location="' . $_SESSION['Side_PHP_SELF'] . '?modcat="+parent.side.document.forms[0].modcat.value;</script>';
                }
                $_REQUEST['next_modname'] = $_REQUEST['modname'];
                include 'modules/Students/Search.inc.php';
            }
            break;
        case 'staff_id':
            // convert profile string to array for legacy compatibility
            if (!is_array($extra)) {
                $extra = array('profile' => $extra);
            }
            if ($_REQUEST['bottom_back']) {
                unset($_SESSION['staff_id']);
                echo '<script type="text/javascript">parent.side.location="' . $_SESSION['Side_PHP_SELF'] . '?modcat="+parent.side.document.forms[0].modcat.value;</script>';
            }
            if ($_REQUEST['staff_id']) {
                if ($_REQUEST['staff_id'] != 'new') {
                    $_SESSION['staff_id'] = $_REQUEST['staff_id'];
                    if ($_REQUEST['school_id']) {
                        $_SESSION['UserSchool'] = $_REQUEST['school_id'];
                    }
                } else {
                    unset($_SESSION['staff_id']);
                }
                if (!isset($_REQUEST['_ROSARIO_PDF'])) {
                    echo '<script type="text/javascript">parent.side.location="' . $_SESSION['Side_PHP_SELF'] . '?modcat="+parent.side.document.forms[0].modcat.value;</script>';
                }
            } elseif (!UserStaffID() || $extra['new'] == true) {
                if (UserStaffID()) {
                    unset($_SESSION['staff_id']);
                    echo '<script type="text/javascript">parent.side.location="' . $_SESSION['Side_PHP_SELF'] . '?modcat="+parent.side.document.forms[0].modcat.value;</script>';
                }
                //if(empty($_REQUEST['modfunc']))
                $_REQUEST['modfunc'] = 'search_fnc';
                $_REQUEST['next_modname'] = $_REQUEST['modname'];
                //if(!$_REQUEST['modname']) $_REQUEST['modname'] = 'Users/Search.php';
                include 'modules/Users/Search.inc.php';
            }
            break;
        case 'general_info':
            echo '<TR><TD style="text-align:right; width:120px:"><label for="last">' . _('Last Name') . '</label></TD><TD><input type="text" name="last" id="last" size="30"></TD></TR>';
            echo '<TR><TD style="text-align:right; width:120px:"><label for="first">' . _('First Name') . '</label></TD><TD><input type="text" name="first" id="first" size="30"></TD></TR>';
            echo '<TR><TD style="text-align:right; width:120px:"><label for="stuid">' . _('RosarioSIS ID') . '</label></TD><TD><input type="text" name="stuid" id="stuid" size="30"></TD></TR>';
            echo '<TR><TD style="text-align:right; width:120px:"><label for="addr">' . _('Address') . '</label></TD><TD><input type="text" name="addr" id="addr" size="30"></TD></TR>';
            $list = DBGet(DBQuery("SELECT ID,TITLE,SHORT_NAME FROM SCHOOL_GRADELEVELS WHERE SCHOOL_ID='" . UserSchool() . "' ORDER BY SORT_ORDER"));
            if ($_REQUEST['advanced'] == 'Y' || is_array($extra)) {
                //modif Francois: add <label> on checkbox
                echo '<TR><TD style="text-align:right; width:120px:">' . _('Grade Levels') . '<BR /><label>' . _('Not') . '&nbsp;<INPUT type="checkbox" name="grades_not" value="Y"></label><BR /><label>' . _('Check All') . '&nbsp;<INPUT type="checkbox" value="Y" name="controller" onclick="checkAll(this.form,this.form.controller.checked,\'grades[\');"></label></TD><TD><TABLE>';
                foreach ($list as $value) {
                    if (!$i) {
                        echo '<TR>';
                        $i = 5;
                    }
                    echo '<TD><label><INPUT type="checkbox" name="grades[' . $value['ID'] . ']" value="Y"' . (is_array($extra) ? $extra[$value['ID']] ? ' checked' : '' : ($extra == $value['ID'] ? ' checked' : '')) . '>&nbsp;' . $value['SHORT_NAME'] . '</label> &nbsp;</TD>';
                    $i--;
                    if (!$i) {
                        echo '</TR>';
                    }
                }
                if (!$i) {
                    echo '</TR>';
                }
                echo '</TABLE></TD></TR>';
            } else {
                echo '<TR><TD style="text-align:right; width:120px:"><label for="grade">' . _('Grade Level') . '</label></TD><TD><SELECT name="grade" id="grade"><OPTION value="">' . _('Not Specified') . '</OPTION>';
                foreach ($list as $value) {
                    echo '<OPTION value="' . $value['ID'] . '"' . ($extra == $value['ID'] ? ' SELECTED="SELECTED"' : '') . '>' . $value['TITLE'] . '</OPTION>';
                }
                echo '</SELECT></TD></TR>';
            }
            break;
        case 'staff_fields':
        case 'staff_fields_all':
        case 'student_fields':
        case 'student_fields_all':
            if ($type == 'staff_fields_all') {
                $categories_RET = ParseMLArray(DBGet(DBQuery("SELECT sfc.ID,sfc.TITLE AS CATEGORY_TITLE,'CUSTOM_'||cf.ID AS COLUMN_NAME,cf.TYPE,cf.TITLE,SELECT_OPTIONS FROM STAFF_FIELD_CATEGORIES sfc,STAFF_FIELDS cf WHERE (SELECT CAN_USE FROM " . (User('PROFILE_ID') ? "PROFILE_EXCEPTIONS WHERE PROFILE_ID='" . User('PROFILE_ID') . "'" : "STAFF_EXCEPTIONS WHERE USER_ID='" . User('STAFF_ID') . "'") . " AND MODNAME='Users/User.php&category_id='||sfc.ID)='Y' AND cf.CATEGORY_ID=sfc.ID AND NOT exists(SELECT '' FROM PROGRAM_USER_CONFIG WHERE PROGRAM='StaffFieldsSearch' AND TITLE=cast(cf.ID AS TEXT) AND USER_ID='" . User('STAFF_ID') . "' AND VALUE='Y') ORDER BY sfc.SORT_ORDER,sfc.TITLE,cf.SORT_ORDER,cf.TITLE"), array(), array('ID', 'TYPE')), array('CATEGORY_TITLE', 'TITLE'));
            } elseif ($type == 'staff_fields') {
                $categories_RET = ParseMLArray(DBGet(DBQuery("SELECT '0' AS ID,'' AS CATEGORY_TITLE,'CUSTOM_'||cf.ID AS COLUMN_NAME,cf.TYPE,cf.TITLE,cf.SELECT_OPTIONS FROM STAFF_FIELDS cf WHERE (SELECT CAN_USE FROM " . (User('PROFILE_ID') ? "PROFILE_EXCEPTIONS WHERE PROFILE_ID='" . User('PROFILE_ID') . "'" : "STAFF_EXCEPTIONS WHERE USER_ID='" . User('STAFF_ID') . "'") . " AND MODNAME='Users/User.php&category_id='||cf.CATEGORY_ID)='Y'  AND ((SELECT VALUE FROM PROGRAM_USER_CONFIG WHERE TITLE=cast(cf.ID AS TEXT) AND PROGRAM='StaffFieldsSearch' AND USER_ID='" . User('STAFF_ID') . "')='Y') ORDER BY cf.SORT_ORDER,cf.TITLE"), array(), array('ID', 'TYPE')), array('CATEGORY_TITLE', 'TITLE'));
            } elseif ($type == 'student_fields_all') {
                $categories_RET = ParseMLArray(DBGet(DBQuery("SELECT sfc.ID,sfc.TITLE AS CATEGORY_TITLE,'CUSTOM_'||cf.ID AS COLUMN_NAME,cf.TYPE,cf.TITLE,SELECT_OPTIONS FROM STUDENT_FIELD_CATEGORIES sfc,CUSTOM_FIELDS cf WHERE (SELECT CAN_USE FROM " . (User('PROFILE_ID') ? "PROFILE_EXCEPTIONS WHERE PROFILE_ID='" . User('PROFILE_ID') . "'" : "STAFF_EXCEPTIONS WHERE USER_ID='" . User('STAFF_ID') . "'") . " AND MODNAME='Students/Student.php&category_id='||sfc.ID)='Y' AND cf.CATEGORY_ID=sfc.ID AND NOT exists(SELECT '' FROM PROGRAM_USER_CONFIG WHERE PROGRAM='StudentFieldsSearch' AND TITLE=cast(cf.ID AS TEXT) AND USER_ID='" . User('STAFF_ID') . "' AND VALUE='Y') ORDER BY sfc.SORT_ORDER,sfc.TITLE,cf.SORT_ORDER,cf.TITLE"), array(), array('ID', 'TYPE')), array('CATEGORY_TITLE', 'TITLE'));
            } else {
                $categories_RET = ParseMLArray(DBGet(DBQuery("SELECT '0' AS ID,'' AS CATEGORY_TITLE,'CUSTOM_'||cf.ID AS COLUMN_NAME,cf.TYPE,cf.TITLE,cf.SELECT_OPTIONS FROM CUSTOM_FIELDS cf WHERE (SELECT CAN_USE FROM " . (User('PROFILE_ID') ? "PROFILE_EXCEPTIONS WHERE PROFILE_ID='" . User('PROFILE_ID') . "'" : "STAFF_EXCEPTIONS WHERE USER_ID='" . User('STAFF_ID') . "'") . " AND MODNAME='Students/Student.php&category_id='||cf.CATEGORY_ID)='Y'  AND ((SELECT VALUE FROM PROGRAM_USER_CONFIG WHERE TITLE=cast(cf.ID AS TEXT) AND PROGRAM='StudentFieldsSearch' AND USER_ID='" . User('STAFF_ID') . "')='Y') ORDER BY cf.SORT_ORDER,cf.TITLE"), array(), array('ID', 'TYPE')), array('CATEGORY_TITLE', 'TITLE'));
            }
            foreach ($categories_RET as $search_fields_RET) {
                if ($type == 'student_fields_all' || $type == 'staff_fields_all') {
                    //modif Francois: css WPadmin
                    echo '<TR><TD colspan="2"><TABLE style="border-collapse:separate; border-spacing:2px" class="width-100p cellpadding-2"><TR><TD colspan="2">&nbsp;<A onclick="switchMenu(\'fields_' . $search_fields_RET[key($search_fields_RET)][1]['ID'] . '_table\');" href="#"><IMG SRC="assets/arrow_right.gif" id="fields_' . $search_fields_RET[key($search_fields_RET)][1]['ID'] . '_table_arrow" height="12"> <B>' . $search_fields_RET[key($search_fields_RET)][1]['CATEGORY_TITLE'] . '</B></A><BR />';
                    echo '<TABLE id="fields_' . $search_fields_RET[key($search_fields_RET)][1]['ID'] . '_table" style="display:none;" class="widefat width-100p cellspacing-0">';
                }
                if (count($search_fields_RET['text'])) {
                    foreach ($search_fields_RET['text'] as $column) {
                        echo '<TR><TD style="text-align:right; width:120px:"><label for="cust[' . $column['COLUMN_NAME'] . ']">' . $column['TITLE'] . '</label></TD><TD><INPUT type="text" name="cust[' . $column['COLUMN_NAME'] . ']" id="cust[' . $column['COLUMN_NAME'] . ']" size="30"></TD></TR>';
                    }
                }
                if (count($search_fields_RET['numeric'])) {
                    foreach ($search_fields_RET['numeric'] as $column) {
                        echo '<TR><TD style="text-align:right; width:120px:">' . $column['TITLE'] . '</TD><TD><span class="sizep2">&ge;</span> <INPUT type="text" name="cust_begin[' . $column['COLUMN_NAME'] . ']" size="3" maxlength="11"> <span class="sizep2">&le;</span> <INPUT type="text" name="cust_end[' . $column['COLUMN_NAME'] . ']" size="3" maxlength="11"> <label>' . _('No Value') . ' <INPUT type="checkbox" name="cust_null[' . $column['COLUMN_NAME'] . ']"></label>&nbsp;</TD></TR>';
                    }
                }
                if (count($search_fields_RET['codeds'])) {
                    foreach ($search_fields_RET['codeds'] as $column) {
                        $column['SELECT_OPTIONS'] = str_replace("\n", "\r", str_replace("\r\n", "\r", $column['SELECT_OPTIONS']));
                        $options = explode("\r", $column['SELECT_OPTIONS']);
                        echo '<TR><TD style="text-align:right; width:120px:">' . $column['TITLE'] . '</TD><TD>';
                        echo '<SELECT name="cust[' . $column['COLUMN_NAME'] . '] style="max-width:250;"><OPTION value="">' . _('N/A') . '</OPTION><OPTION value="!">' . _('No Value') . '</OPTION>';
                        foreach ($options as $option) {
                            $option = explode('|', $option);
                            if ($option[0] != '' && $option[1] != '') {
                                echo '<OPTION value="' . $option[0] . '">' . $option[1] . '</OPTION>';
                            }
                        }
                        echo '</SELECT>';
                        echo '</TD></TR>';
                    }
                }
                if (count($search_fields_RET['exports'])) {
                    foreach ($search_fields_RET['exports'] as $column) {
                        $column['SELECT_OPTIONS'] = str_replace("\n", "\r", str_replace("\r\n", "\r", $column['SELECT_OPTIONS']));
                        $options = explode("\r", $column['SELECT_OPTIONS']);
                        echo '<TR><TD style="text-align:right; width:120px:">' . $column['TITLE'] . '</TD><TD>';
                        echo '<SELECT name="cust[' . $column['COLUMN_NAME'] . '] style="max-width:250;"><OPTION value="">' . _('N/A') . '</OPTION><OPTION value="!">' . _('No Value') . '</OPTION>';
                        foreach ($options as $option) {
                            $option = explode('|', $option);
                            if ($option[0] != '') {
                                echo '<OPTION value="$option[0]">' . $option[0] . '</OPTION>';
                            }
                        }
                        echo '</SELECT>';
                        echo '</TD></TR>';
                    }
                }
                if (count($search_fields_RET['select'])) {
                    foreach ($search_fields_RET['select'] as $column) {
                        $column['SELECT_OPTIONS'] = str_replace("\n", "\r", str_replace("\r\n", "\r", $column['SELECT_OPTIONS']));
                        $options = explode("\r", $column['SELECT_OPTIONS']);
                        echo '<TR><TD style="text-align:right; width:120px:">' . $column['TITLE'] . '</TD><TD>';
                        echo '<SELECT name="cust[' . $column['COLUMN_NAME'] . '] style="max-width:250;"><OPTION value="">' . _('N/A') . '</OPTION><OPTION value="!">' . _('No Value') . '</OPTION>';
                        foreach ($options as $option) {
                            echo '<OPTION value="' . $option . '">' . $option . '</OPTION>';
                        }
                        echo '</SELECT>';
                        echo '</TD></TR>';
                    }
                }
                if (count($search_fields_RET['autos'])) {
                    foreach ($search_fields_RET['autos'] as $column) {
                        if ($column['SELECT_OPTIONS']) {
                            $column['SELECT_OPTIONS'] = str_replace("\n", "\r", str_replace("\r\n", "\r", $column['SELECT_OPTIONS']));
                            $options_RET = explode("\r", $column['SELECT_OPTIONS']);
                        } else {
                            $options_RET = array();
                        }
                        echo '<TR><TD style="text-align:right; width:120px:">' . $column['TITLE'] . '</TD><TD>';
                        echo '<SELECT name="cust[' . $column['COLUMN_NAME'] . '] style="max-width:250;"><OPTION value="">' . _('N/A') . '</OPTION><OPTION value="!">' . _('No Value') . '</OPTION>';
                        $options = array();
                        foreach ($options_RET as $option) {
                            echo '<OPTION value="' . $option . '">' . $option . '</OPTION>';
                            $options[$option] = true;
                        }
                        //modif Francois: new option
                        echo '<OPTION value="---">-' . _('Edit') . '-</OPTION>';
                        $options['---'] = true;
                        // add values found in current and previous year
                        $options_RET = DBGet(DBQuery("SELECT DISTINCT s.{$column['COLUMN_NAME']},upper(s.{$column['COLUMN_NAME']}) AS KEY FROM STUDENTS s,STUDENT_ENROLLMENT sse WHERE sse.STUDENT_ID=s.STUDENT_ID AND (sse.SYEAR='" . UserSyear() . "' OR sse.SYEAR='" . (UserSyear() - 1) . "') AND {$column['COLUMN_NAME']} IS NOT NULL ORDER BY KEY"));
                        foreach ($options_RET as $option) {
                            if ($option[$column['COLUMN_NAME']] != '' && !$options[$option[$column['COLUMN_NAME']]]) {
                                echo '<OPTION value="' . $option[$column['COLUMN_NAME']] . '">' . $option[$column['COLUMN_NAME']] . '</OPTION>';
                                $options[$option[$column['COLUMN_NAME']]] = true;
                            }
                        }
                        echo '</SELECT>';
                        echo '</TD></TR>';
                    }
                }
                if (count($search_fields_RET['edits'])) {
                    foreach ($search_fields_RET['edits'] as $column) {
                        if ($column['SELECT_OPTIONS']) {
                            $column['SELECT_OPTIONS'] = str_replace("\n", "\r", str_replace("\r\n", "\r", $column['SELECT_OPTIONS']));
                            $options_RET = explode("\r", $column['SELECT_OPTIONS']);
                        } else {
                            $options_RET = array();
                        }
                        echo '<TR><TD style="text-align:right; width:120px:">' . $column['TITLE'] . '</TD><TD>';
                        echo '<SELECT name="cust[' . $column['COLUMN_NAME'] . '] style="max-width:250;"><OPTION value="">' . _('N/A') . '</OPTION><OPTION value="!">' . _('No Value') . '</OPTION>';
                        $options = array();
                        foreach ($options_RET as $option) {
                            echo '<OPTION value="' . $option . '">' . $option . '</OPTION>';
                        }
                        //modif Francois: new option
                        //						echo "<OPTION value=\"---\">---</OPTION>";
                        echo '<OPTION value="---">-' . _('Edit') . '-</OPTION>';
                        echo '<OPTION value="~">' . _('Other Value') . '</OPTION>';
                        echo '</SELECT>';
                        echo '</TD></TR>';
                    }
                }
                if (count($search_fields_RET['date'])) {
                    foreach ($search_fields_RET['date'] as $column) {
                        echo '<TR><TD style="text-align:right; width:120px:">' . $column['TITLE'] . '<BR /><label>' . _('No Value') . '&nbsp;<INPUT type="checkbox" name="cust_null[' . $column['COLUMN_NAME'] . ']"></label></TD><TD><table class="cellpadding-0 cellspacing-0"<tr><td><span class="sizep2">&ge;</span>&nbsp;</td><td>' . PrepareDate('', '_cust_begin[' . $column['COLUMN_NAME'] . ']', true, array('short' => true)) . '</td></tr><tr><td><span class="sizep2">&le;</span>&nbsp;</td><td>' . PrepareDate('', '_cust_end[' . $column['COLUMN_NAME'] . ']', true, array('short' => true)) . '</td></tr></table></TD></TR>';
                    }
                }
                if (count($search_fields_RET['radio'])) {
                    echo '<TR><TD colspan="2"><TABLE>';
                    echo '<TR><TD style="width:120px;"></TD><TD><TABLE class="cellpadding-0 cellspacing-0"><tr><td style="width:25px;"><b>' . _('All') . '</b></td><td style="width:30px;"><b>' . _('Yes') . '</b></td><td style="width:25px;"><b>' . _('No') . '</b></td></tr></table></TD><TD>&nbsp;</TD>';
                    if (count($search_fields_RET['radio']) > 1) {
                        echo '<TD style="width:120px;"></TD><TD><TABLE class="cellpadding-0 cellspacing-0"><tr><td style="width:25px;"><b>' . _('All') . '</b></td><td style="width:30px;"><b>' . _('Yes') . '</b></td><td style="width:25px;"><b>' . _('No') . '</b></td></tr></table></TD><TD>&nbsp;</TD>';
                    }
                    echo '</TR>';
                    $side = 0;
                    foreach ($search_fields_RET['radio'] as $cust) {
                        if (!$side) {
                            echo '<TR>';
                        }
                        echo '<TD style="text-align:right; width:120px">' . $cust['TITLE'] . '</TD><TD>
						<TABLE class="cellpadding-0 cellspacing-0"><tr><td style="text-align:center; width:25px;">
						<input name="cust[' . $cust['COLUMN_NAME'] . ']" type="radio" value="" checked />
						</td><td style="text-align:center; width:30px;">
						<input name="cust[' . $cust['COLUMN_NAME'] . ']" type="radio" value="Y" />
						</td><td style="text-align:center; width:25px;">
						<input name="cust[' . $cust['COLUMN_NAME'] . ']" type="radio" value="N" />
						</td></tr></table>
						</TD><TD>&nbsp;</TD>';
                        if ($side) {
                            echo '</TR>';
                        }
                        $side = 1 - $side;
                    }
                    if ($side) {
                        echo '</TR>';
                    }
                    echo '</TABLE></TD></TR>';
                }
                if ($type == 'student_fields_all' || $type == 'staff_fields_all') {
                    //					echo '</TABLE>';
                    echo '</TABLE></TD></TR></TABLE></TD></TR>';
                }
            }
            break;
    }
}
function CustomFields($location, $type = 'student', $extra = array())
{
    global $_ROSARIO;
    if (count($_REQUEST['month_cust_begin'])) {
        foreach ($_REQUEST['month_cust_begin'] as $field_name => $month) {
            $_REQUEST['cust_begin'][$field_name] = $_REQUEST['day_cust_begin'][$field_name] . '-' . $month . '-' . $_REQUEST['year_cust_begin'][$field_name];
            if (!VerifyDate($_REQUEST['cust_begin'][$field_name])) {
                unset($_REQUEST['cust_begin'][$field_name]);
            }
        }
    }
    unset($_REQUEST['month_cust_begin']);
    unset($_REQUEST['year_cust_begin']);
    unset($_REQUEST['day_cust_begin']);
    if (count($_REQUEST['month_cust_end'])) {
        foreach ($_REQUEST['month_cust_end'] as $field_name => $month) {
            $_REQUEST['cust_end'][$field_name] = $_REQUEST['day_cust_end'][$field_name] . '-' . $month . '-' . $_REQUEST['year_cust_end'][$field_name];
            if (!VerifyDate($_REQUEST['cust_end'][$field_name])) {
                unset($_REQUEST['cust_end'][$field_name]);
            }
        }
    }
    unset($_REQUEST['month_cust_end']);
    unset($_REQUEST['year_cust_end']);
    unset($_REQUEST['day_cust_end']);
    if (count($_REQUEST['cust'])) {
        foreach ($_REQUEST['cust'] as $key => $value) {
            if ($value == '') {
                unset($_REQUEST['cust'][$key]);
            }
        }
    }
    switch ($location) {
        case 'from':
            break;
        case 'where':
            if (count($_REQUEST['cust']) || count($_REQUEST['cust_begin'] || count($_REQUEST['cust_null']))) {
                $fields = ParseMLArray(DBGet(DBQuery("SELECT TITLE,ID,TYPE,SELECT_OPTIONS FROM " . ($type == 'staff' ? 'STAFF' : 'CUSTOM') . "_FIELDS"), array(), array('ID')), 'TITLE');
            }
            if (count($_REQUEST['cust'])) {
                foreach ($_REQUEST['cust'] as $field_name => $value) {
                    if ($value != '') {
                        switch ($fields[mb_substr($field_name, 7)][1]['TYPE']) {
                            case 'radio':
                                if (!$extra['NoSearchTerms']) {
                                    $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . $fields[mb_substr($field_name, 7)][1]['TITLE'] . ': </b></span>';
                                }
                                if ($value == 'Y') {
                                    $string .= " AND s.{$field_name}='{$value}' ";
                                    if (!$extra['NoSearchTerms']) {
                                        $_ROSARIO['SearchTerms'] .= _('Yes');
                                    }
                                } elseif ($value == 'N') {
                                    $string .= " AND (s.{$field_name}!='Y' OR s.{$field_name} IS NULL) ";
                                    if (!$extra['NoSearchTerms']) {
                                        $_ROSARIO['SearchTerms'] .= _('No');
                                    }
                                }
                                if (!$extra['NoSearchTerms']) {
                                    $_ROSARIO['SearchTerms'] .= '<BR />';
                                }
                                break;
                            case 'codeds':
                                if (!$extra['NoSearchTerms']) {
                                    $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . $fields[mb_substr($field_name, 7)][1]['TITLE'] . ': </b></span>';
                                }
                                if ($value == '!') {
                                    $string .= " AND (s.{$field_name}='' OR s.{$field_name} IS NULL) ";
                                    if (!$extra['NoSearchTerms']) {
                                        $_ROSARIO['SearchTerms'] .= _('No Value');
                                    }
                                } else {
                                    $string .= " AND s.{$field_name}='{$value}' ";
                                    if (!$extra['NoSearchTerms']) {
                                        $select_options = str_replace("\n", "\r", str_replace("\r\n", "\r", $fields[mb_substr($field_name, 7)][1]['SELECT_OPTIONS']));
                                        $select_options = explode("\r", $select_options);
                                        foreach ($select_options as $option) {
                                            $option = explode('|', $option);
                                            if ($option[0] != '' && $option[1] != '' && $value == $option[0]) {
                                                $value = $option[1];
                                                break;
                                            }
                                        }
                                        $_ROSARIO['SearchTerms'] .= $value;
                                    }
                                }
                                if (!$extra['NoSearchTerms']) {
                                    $_ROSARIO['SearchTerms'] .= '<BR />';
                                }
                                break;
                            case 'exports':
                                if (!$extra['NoSearchTerms']) {
                                    $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . $fields[mb_substr($field_name, 7)][1]['TITLE'] . ': </b></span>';
                                }
                                if ($value == '!') {
                                    $string .= " AND (s.{$field_name}='' OR s.{$field_name} IS NULL) ";
                                    if (!$extra['NoSearchTerms']) {
                                        $_ROSARIO['SearchTerms'] .= _('No Value');
                                    }
                                } else {
                                    $string .= " AND s.{$field_name}='{$value}' ";
                                    if (!$extra['NoSearchTerms']) {
                                        $select_options = str_replace("\n", "\r", str_replace("\r\n", "\r", $fields[mb_substr($field_name, 7)][1]['SELECT_OPTIONS']));
                                        $select_options = explode("\r", $select_options);
                                        foreach ($select_options as $option) {
                                            $option = explode('|', $option);
                                            if ($option[0] != '' && $value == $option[0]) {
                                                $value = $option[0];
                                                break;
                                            }
                                        }
                                        $_ROSARIO['SearchTerms'] .= $value;
                                    }
                                }
                                if (!$extra['NoSearchTerms']) {
                                    $_ROSARIO['SearchTerms'] .= '<BR />';
                                }
                                break;
                            case 'select':
                                if (!$extra['NoSearchTerms']) {
                                    $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . $fields[mb_substr($field_name, 7)][1]['TITLE'] . ': </b></span>';
                                }
                                if ($value == '!') {
                                    $string .= " AND (s.{$field_name}='' OR s.{$field_name} IS NULL) ";
                                    if (!$extra['NoSearchTerms']) {
                                        $_ROSARIO['SearchTerms'] .= _('No Value');
                                    }
                                } else {
                                    $string .= " AND s.{$field_name}='{$value}' ";
                                    if (!$extra['NoSearchTerms']) {
                                        $_ROSARIO['SearchTerms'] .= $value;
                                    }
                                }
                                if (!$extra['NoSearchTerms']) {
                                    $_ROSARIO['SearchTerms'] .= '<BR />';
                                }
                                break;
                            case 'autos':
                                if (!$extra['NoSearchTerms']) {
                                    $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . $fields[mb_substr($field_name, 7)][1]['TITLE'] . ': </b></span>';
                                }
                                if ($value == '!') {
                                    $string .= " AND (s.{$field_name}='' OR s.{$field_name} IS NULL) ";
                                    if (!$extra['NoSearchTerms']) {
                                        $_ROSARIO['SearchTerms'] .= _('No Value');
                                    }
                                } else {
                                    $string .= " AND s.{$field_name}='{$value}' ";
                                    if (!$extra['NoSearchTerms']) {
                                        $_ROSARIO['SearchTerms'] .= $value;
                                    }
                                }
                                if (!$extra['NoSearchTerms']) {
                                    $_ROSARIO['SearchTerms'] .= '<BR />';
                                }
                                break;
                            case 'edits':
                                if (!$extra['NoSearchTerms']) {
                                    $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . $fields[mb_substr($field_name, 7)][1]['TITLE'] . ': </b></span>';
                                }
                                if ($value == '!') {
                                    $string .= " AND (s.{$field_name}='' OR s.{$field_name} IS NULL) ";
                                    if (!$extra['NoSearchTerms']) {
                                        $_ROSARIO['SearchTerms'] .= _('No Value');
                                    }
                                } elseif ($value == '~') {
                                    $string .= " AND position('\r'||s.{$field_name}||'\r' IN '\r'||(SELECT SELECT_OPTIONS FROM " . ($type == 'staff' ? 'STAFF' : 'CUSTOM') . "_FIELDS WHERE ID='" . mb_substr($field_name, 7) . "')||'\r')=0 ";
                                    if (!$extra['NoSearchTerms']) {
                                        $_ROSARIO['SearchTerms'] .= _('Other Value');
                                    }
                                } else {
                                    $string .= " AND s.{$field_name}='{$value}' ";
                                    if (!$extra['NoSearchTerms']) {
                                        $_ROSARIO['SearchTerms'] .= $value;
                                    }
                                }
                                if (!$extra['NoSearchTerms']) {
                                    $_ROSARIO['SearchTerms'] .= '<BR />';
                                }
                                break;
                            case 'text':
                                if ($value == '!') {
                                    $string .= " AND (s.{$field_name}='' OR s.{$field_name} IS NULL) ";
                                    if (!$extra['NoSearchTerms']) {
                                        $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . $fields[mb_substr($field_name, 7)][1]['TITLE'] . ': </b></span>' . _('No Value') . '<BR />';
                                    }
                                } elseif (mb_substr($value, 0, 2) == '\\"' && mb_substr($value, -2) == '\\"') {
                                    $string .= " AND s.{$field_name}='" . mb_substr($value, 2, -2) . "' ";
                                    if (!$extra['NoSearchTerms']) {
                                        $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . $fields[mb_substr($field_name, 7)][1]['TITLE'] . ': </b></span>' . mb_substr($value, 2, -2) . '<BR />';
                                    }
                                } else {
                                    $string .= " AND LOWER(s.{$field_name}) LIKE '" . mb_strtolower($value) . "%' ";
                                    if (!$extra['NoSearchTerms']) {
                                        $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . $fields[mb_substr($field_name, 7)][1]['TITLE'] . '&nbsp;' . Localize('colon', _('starts with')) . ' </b></span>' . str_replace("''", "'", $value) . '<BR />';
                                    }
                                }
                                break;
                        }
                    }
                }
            }
            if (count($_REQUEST['cust_begin'])) {
                foreach ($_REQUEST['cust_begin'] as $field_name => $value) {
                    if ($fields[mb_substr($field_name, 7)][1]['TYPE'] == 'numeric') {
                        $value = preg_replace('/[^0-9.-]+/', '', $value);
                    }
                    if ($value != '') {
                        $string .= " AND s.{$field_name} >= '{$value}' ";
                        if (!$extra['NoSearchTerms']) {
                            if ($fields[mb_substr($field_name, 7)][1]['TYPE'] == 'date') {
                                $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . $fields[mb_substr($field_name, 7)][1]['TITLE'] . ' <span class="sizep2">&ge;</span> </b></span>' . ProperDate($value) . '<BR />';
                            } else {
                                $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . $fields[mb_substr($field_name, 7)][1]['TITLE'] . ' <span class="sizep2">&ge;</span> </b></span>' . $value . '<BR />';
                            }
                        }
                    }
                }
            }
            if (count($_REQUEST['cust_end'])) {
                foreach ($_REQUEST['cust_end'] as $field_name => $value) {
                    if ($fields[mb_substr($field_name, 7)][1]['TYPE'] == 'numeric') {
                        $value = preg_replace('/[^0-9.-]+/', '', $value);
                    }
                    if ($value != '') {
                        $string .= " AND s.{$field_name} <= '{$value}' ";
                        if (!$extra['NoSearchTerms']) {
                            if ($fields[mb_substr($field_name, 7)][1]['TYPE'] == 'date') {
                                $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . $fields[mb_substr($field_name, 7)][1]['TITLE'] . ' <span class="sizep2">&le;</span> </b></span>' . ProperDate($value) . '<BR />';
                            } else {
                                $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . $fields[mb_substr($field_name, 7)][1]['TITLE'] . ' <span class="sizep2">&le;</span> </b></span>' . $value . '<BR />';
                            }
                        }
                    }
                }
            }
            if (count($_REQUEST['cust_null'])) {
                foreach ($_REQUEST['cust_null'] as $field_name => $y) {
                    $string .= " AND s.{$field_name} IS NULL ";
                    if (!$extra['NoSearchTerms']) {
                        $_ROSARIO['SearchTerms'] .= '<span style="color:gray"><b>' . $fields[mb_substr($field_name, 7)][1]['TITLE'] . ': </b></span>' . _('No Value') . '<BR />';
                    }
                }
            }
            break;
    }
    return $string;
}
Example #5
0
function Search($type, $extra = null)
{
    global $_CENTRE;
    switch ($type) {
        case 'student_id':
            if ($_REQUEST['bottom_back']) {
                unset($_SESSION['student_id']);
                echo '<script language=JavaScript>parent.side.location="' . $_SESSION['Side_PHP_SELF'] . '?modcat="+parent.side.document.forms[0].modcat.value;</script>';
            }
            if ($_SESSION['unset_student']) {
                unset($_REQUEST['student_id']);
                unset($_SESSION['unset_student']);
            }
            if ($_REQUEST['student_id']) {
                if ($_REQUEST['student_id'] != 'new') {
                    $_SESSION['student_id'] = $_REQUEST['student_id'];
                    if ($_REQUEST['school_id']) {
                        $_SESSION['UserSchool'] = $_REQUEST['school_id'];
                    }
                } else {
                    unset($_SESSION['student_id']);
                }
                if (!$_REQUEST['_CENTRE_PDF']) {
                    echo '<script language=JavaScript>parent.side.location="' . $_SESSION['Side_PHP_SELF'] . '?modcat="+parent.side.document.forms[0].modcat.value;</script>';
                }
            } elseif (!UserStudentID() || $extra['new'] == true) {
                if (UserStudentID()) {
                    //unset($_SESSION['student_id']);
                    echo '<script language=JavaScript>parent.side.location="' . $_SESSION['Side_PHP_SELF'] . '?modcat="+parent.side.document.forms[0].modcat.value;</script>';
                }
                $_REQUEST['next_modname'] = $_REQUEST['modname'];
                include 'modules/Students/Search.inc.php';
            }
            break;
        case 'staff_id':
            // convert profile string to array for legacy compatibility
            if (!is_array($extra)) {
                $extra = array('profile' => $extra);
            }
            if ($_REQUEST['bottom_back']) {
                unset($_SESSION['staff_id']);
                echo '<script language=JavaScript>parent.side.location="' . $_SESSION['Side_PHP_SELF'] . '?modcat="+parent.side.document.forms[0].modcat.value;</script>';
            }
            if ($_REQUEST['staff_id']) {
                if ($_REQUEST['staff_id'] != 'new') {
                    $_SESSION['staff_id'] = $_REQUEST['staff_id'];
                    if ($_REQUEST['school_id']) {
                        $_SESSION['UserSchool'] = $_REQUEST['school_id'];
                    }
                } else {
                    unset($_SESSION['staff_id']);
                }
                if (!$_REQUEST['_CENTRE_PDF']) {
                    echo '<script language=JavaScript>parent.side.location="' . $_SESSION['Side_PHP_SELF'] . '?modcat="+parent.side.document.forms[0].modcat.value;</script>';
                }
            } elseif (!UserStaffID() || $extra['new'] == true) {
                if (UserStaffID()) {
                    unset($_SESSION['staff_id']);
                    echo '<script language=JavaScript>parent.side.location="' . $_SESSION['Side_PHP_SELF'] . '?modcat="+parent.side.document.forms[0].modcat.value;</script>';
                }
                //if(!$_REQUEST['modfunc']) $_REQUEST['modfunc'] = 'search_fnc';
                $_REQUEST['next_modname'] = $_REQUEST['modname'];
                //if(!$_REQUEST['modname']) $_REQUEST['modname'] = 'Users/Search.php';
                include 'modules/Users/Search.inc.php';
            }
            break;
        case 'general_info':
            echo '<TR><TD align=right width=120>' . _('Last Name') . '</TD><TD><input type=text name="last" size=30></TD></TR>';
            echo '<TR><TD align=right width=120>' . _('First Name') . '</TD><TD><input type=text name="first" size=30></TD></TR>';
            echo '<TR><TD align=right width=120>' . _('Centre ID') . '</TD><TD><input type=text name="stuid" size=30></TD></TR>';
            echo '<TR><TD align=right width=120>' . _('Address') . '</TD><TD><input type=text name="addr" size=30></TD></TR>';
            $list = DBGet(DBQuery("SELECT ID,TITLE,SHORT_NAME FROM SCHOOL_GRADELEVELS WHERE SCHOOL_ID='" . UserSchool() . "' ORDER BY SORT_ORDER"));
            if ($_REQUEST['advanced'] == 'Y' || is_array($extra)) {
                echo '<TR><TD align=right width=120>' . _('Grades') . '<BR>' . _('Not') . '<INPUT type=checkbox name=grades_not value=Y><BR><small>' . _('Check All') . '</small><INPUT type=checkbox value=Y name=controller onclick="checkAll(this.form,this.form.controller.checked,\'grades[\');"></TD><TD><TABLE>';
                foreach ($list as $value) {
                    if (!$i) {
                        echo '<TR>';
                        $i = 5;
                    }
                    echo '<TD><INPUT type=checkbox name=grades[' . $value['ID'] . '] value=Y' . (is_array($extra) ? $extra[$value['ID']] ? ' checked' : '' : ($extra == $value['ID'] ? ' checked' : '')) . '>' . $value['SHORT_NAME'] . '</TD>';
                    $i--;
                    if (!$i) {
                        echo '</TR>';
                    }
                }
                if (!$i) {
                    echo '</TR>';
                }
                echo '</TABLE></TD></TR>';
            } else {
                echo '<TR><TD align=right width=120>' . _('Grade') . '</TD><TD><SELECT name=grade><OPTION value="">' . _('Not Specified') . '</OPTION>';
                foreach ($list as $value) {
                    echo '<OPTION value=' . $value['ID'] . ($extra == $value['ID'] ? ' selected' : '') . '>' . $value['TITLE'] . '</OPTION>';
                }
                echo '</SELECT></TD></TR>';
            }
            break;
        case 'staff_fields':
        case 'staff_fields_all':
        case 'student_fields':
        case 'student_fields_all':
            if ($type == 'staff_fields_all') {
                $categories_RET = ParseMLArray(DBGet(DBQuery("SELECT sfc.ID,sfc.TITLE AS CATEGORY_TITLE,'CUSTOM_'||cf.ID AS COLUMN_NAME,cf.TYPE,cf.TITLE,SELECT_OPTIONS FROM STAFF_FIELD_CATEGORIES sfc,STAFF_FIELDS cf WHERE (SELECT CAN_USE FROM " . (User('PROFILE_ID') ? "PROFILE_EXCEPTIONS WHERE PROFILE_ID='" . User('PROFILE_ID') . "'" : "STAFF_EXCEPTIONS WHERE USER_ID='" . User('STAFF_ID') . "'") . " AND MODNAME='Users/User.php&category_id='||sfc.ID)='Y' AND cf.CATEGORY_ID=sfc.ID AND NOT exists(SELECT '' FROM PROGRAM_USER_CONFIG WHERE PROGRAM='StaffFieldsSearch' AND TITLE=cast(cf.ID AS TEXT) AND USER_ID='" . User('STAFF_ID') . "' AND VALUE='Y') ORDER BY sfc.SORT_ORDER,sfc.TITLE,cf.SORT_ORDER,cf.TITLE"), array(), array('ID', 'TYPE')), array('CATEGORY_TITLE', 'TITLE'));
            } elseif ($type == 'staff_fields') {
                $categories_RET = ParseMLArray(DBGet(DBQuery("SELECT '0' AS ID,'' AS CATEGORY_TITLE,'CUSTOM_'||cf.ID AS COLUMN_NAME,cf.TYPE,cf.TITLE,cf.SELECT_OPTIONS FROM STAFF_FIELDS cf WHERE (SELECT CAN_USE FROM " . (User('PROFILE_ID') ? "PROFILE_EXCEPTIONS WHERE PROFILE_ID='" . User('PROFILE_ID') . "'" : "STAFF_EXCEPTIONS WHERE USER_ID='" . User('STAFF_ID') . "'") . " AND MODNAME='Users/User.php&category_id='||cf.CATEGORY_ID)='Y'  AND ((SELECT VALUE FROM PROGRAM_USER_CONFIG WHERE TITLE=cast(cf.ID AS TEXT) AND PROGRAM='StaffFieldsSearch' AND USER_ID='" . User('STAFF_ID') . "')='Y') ORDER BY cf.SORT_ORDER,cf.TITLE"), array(), array('ID', 'TYPE')), array('CATEGORY_TITLE', 'TITLE'));
            } elseif ($type == 'student_fields_all') {
                $categories_RET = ParseMLArray(DBGet(DBQuery("SELECT sfc.ID,sfc.TITLE AS CATEGORY_TITLE,'CUSTOM_'||cf.ID AS COLUMN_NAME,cf.TYPE,cf.TITLE,SELECT_OPTIONS FROM STUDENT_FIELD_CATEGORIES sfc,CUSTOM_FIELDS cf WHERE (SELECT CAN_USE FROM " . (User('PROFILE_ID') ? "PROFILE_EXCEPTIONS WHERE PROFILE_ID='" . User('PROFILE_ID') . "'" : "STAFF_EXCEPTIONS WHERE USER_ID='" . User('STAFF_ID') . "'") . " AND MODNAME='Students/Student.php&category_id='||sfc.ID)='Y' AND cf.CATEGORY_ID=sfc.ID AND NOT exists(SELECT '' FROM PROGRAM_USER_CONFIG WHERE PROGRAM='StudentFieldsSearch' AND TITLE=cast(cf.ID AS TEXT) AND USER_ID='" . User('STAFF_ID') . "' AND VALUE='Y') ORDER BY sfc.SORT_ORDER,sfc.TITLE,cf.SORT_ORDER,cf.TITLE"), array(), array('ID', 'TYPE')), array('CATEGORY_TITLE', 'TITLE'));
            } else {
                $categories_RET = ParseMLArray(DBGet(DBQuery("SELECT '0' AS ID,'' AS CATEGORY_TITLE,'CUSTOM_'||cf.ID AS COLUMN_NAME,cf.TYPE,cf.TITLE,cf.SELECT_OPTIONS FROM CUSTOM_FIELDS cf WHERE (SELECT CAN_USE FROM " . (User('PROFILE_ID') ? "PROFILE_EXCEPTIONS WHERE PROFILE_ID='" . User('PROFILE_ID') . "'" : "STAFF_EXCEPTIONS WHERE USER_ID='" . User('STAFF_ID') . "'") . " AND MODNAME='Students/Student.php&category_id='||cf.CATEGORY_ID)='Y'  AND ((SELECT VALUE FROM PROGRAM_USER_CONFIG WHERE TITLE=cast(cf.ID AS TEXT) AND PROGRAM='StudentFieldsSearch' AND USER_ID='" . User('STAFF_ID') . "')='Y') ORDER BY cf.SORT_ORDER,cf.TITLE"), array(), array('ID', 'TYPE')), array('CATEGORY_TITLE', 'TITLE'));
            }
            foreach ($categories_RET as $search_fields_RET) {
                if ($type == 'student_fields_all' || $type == 'staff_fields_all') {
                    echo '<A onclick="switchMenu(\'fields_' . $search_fields_RET[key($search_fields_RET)][1]['ID'] . '_table\');"><IMG SRC=assets/arrow_right.gif id=fields_' . $search_fields_RET[key($search_fields_RET)][1]['ID'] . '_table_arrow> <B>' . $search_fields_RET[key($search_fields_RET)][1]['CATEGORY_TITLE'] . '</B></A><BR>';
                    echo '<TABLE width=100% border=0 bgcolor=#f8f8f9 id=fields_' . $search_fields_RET[key($search_fields_RET)][1]['ID'] . '_table style="display:none;">';
                }
                if (count($search_fields_RET['text'])) {
                    foreach ($search_fields_RET['text'] as $column) {
                        echo "<TR><TD align=right width=120>{$column['TITLE']}</TD><TD><INPUT type=text name=cust[{$column[COLUMN_NAME]}] size=30></TD></TR>";
                    }
                }
                if (count($search_fields_RET['numeric'])) {
                    foreach ($search_fields_RET['numeric'] as $column) {
                        echo "<TR><TD align=right width=120>{$column['TITLE']}</TD><TD>&ge; <INPUT type=text name=cust_begin[{$column[COLUMN_NAME]}] size=3 maxlength=11> &le; <INPUT type=text name=cust_end[{$column[COLUMN_NAME]}] size=3 maxlength=11> <small>" . _('No Value') . "</small><INPUT type=checkbox name=cust_null[{$column['COLUMN_NAME']}]></TD></TR>";
                    }
                }
                if (count($search_fields_RET['codeds'])) {
                    foreach ($search_fields_RET['codeds'] as $column) {
                        $column['SELECT_OPTIONS'] = str_replace("\n", "\r", str_replace("\r\n", "\r", $column['SELECT_OPTIONS']));
                        $options = explode("\r", $column['SELECT_OPTIONS']);
                        echo "<TR><TD align=right width=120>{$column['TITLE']}</TD><TD>";
                        echo "<SELECT name=cust[{$column[COLUMN_NAME]}] style='max-width:250;'><OPTION value=''>" . _('N/A') . "</OPTION><OPTION value='!'>" . _('No Value') . "</OPTION>";
                        foreach ($options as $option) {
                            $option = explode('|', $option);
                            if ($option[0] != '' && $option[1] != '') {
                                echo "<OPTION value=\"{$option['0']}\">{$option['1']}</OPTION>";
                            }
                        }
                        echo '</SELECT>';
                        echo "</TD></TR>";
                    }
                }
                if (count($search_fields_RET['exports'])) {
                    foreach ($search_fields_RET['exports'] as $column) {
                        $column['SELECT_OPTIONS'] = str_replace("\n", "\r", str_replace("\r\n", "\r", $column['SELECT_OPTIONS']));
                        $options = explode("\r", $column['SELECT_OPTIONS']);
                        echo "<TR><TD align=right width=120>{$column['TITLE']}</TD><TD>";
                        echo "<SELECT name=cust[{$column[COLUMN_NAME]}] style='max-width:250;'><OPTION value=''>" . _('N/A') . "</OPTION><OPTION value='!'>" . _('No Value') . "</OPTION>";
                        foreach ($options as $option) {
                            $option = explode('|', $option);
                            if ($option[0] != '') {
                                echo "<OPTION value=\"{$option['0']}\">{$option['0']}</OPTION>";
                            }
                        }
                        echo '</SELECT>';
                        echo "</TD></TR>";
                    }
                }
                if (count($search_fields_RET['select'])) {
                    foreach ($search_fields_RET['select'] as $column) {
                        $column['SELECT_OPTIONS'] = str_replace("\n", "\r", str_replace("\r\n", "\r", $column['SELECT_OPTIONS']));
                        $options = explode("\r", $column['SELECT_OPTIONS']);
                        echo "<TR><TD align=right width=120>{$column['TITLE']}</TD><TD>";
                        echo "<SELECT name=cust[{$column[COLUMN_NAME]}] style='max-width:250;'><OPTION value=''>" . _('N/A') . "</OPTION><OPTION value='!'>" . _('No Value') . "</OPTION>";
                        foreach ($options as $option) {
                            echo "<OPTION value=\"{$option}\">{$option}</OPTION>";
                        }
                        echo '</SELECT>';
                        echo "</TD></TR>";
                    }
                }
                if (count($search_fields_RET['autos'])) {
                    foreach ($search_fields_RET['autos'] as $column) {
                        if ($column['SELECT_OPTIONS']) {
                            $column['SELECT_OPTIONS'] = str_replace("\n", "\r", str_replace("\r\n", "\r", $column['SELECT_OPTIONS']));
                            $options_RET = explode("\r", $column['SELECT_OPTIONS']);
                        } else {
                            $options_RET = array();
                        }
                        echo "<TR><TD align=right width=120>{$column['TITLE']}</TD><TD>";
                        echo "<SELECT name=cust[{$column[COLUMN_NAME]}] style='max-width:250;'><OPTION value=''>" . _('N/A') . "</OPTION><OPTION value='!'>" . _('No Value') . "</OPTION>";
                        $options = array();
                        foreach ($options_RET as $option) {
                            echo "<OPTION value=\"{$option}\">{$option}</OPTION>";
                            $options[$option] = true;
                        }
                        echo "<OPTION value=\"---\">---</OPTION>";
                        $options['---'] = true;
                        // add values found in current and previous year
                        $options_RET = DBGet(DBQuery("SELECT DISTINCT s.{$column['COLUMN_NAME']},upper(s.{$column['COLUMN_NAME']}) AS KEY FROM STUDENTS s,STUDENT_ENROLLMENT sse WHERE sse.STUDENT_ID=s.STUDENT_ID AND (sse.SYEAR='" . UserSyear() . "' OR sse.SYEAR='" . (UserSyear() - 1) . "') AND {$column['COLUMN_NAME']} IS NOT NULL ORDER BY KEY"));
                        foreach ($options_RET as $option) {
                            if ($option[$column['COLUMN_NAME']] != '' && !$options[$option[$column['COLUMN_NAME']]]) {
                                echo "<OPTION value=\"" . $option[$column['COLUMN_NAME']] . "\">" . $option[$column['COLUMN_NAME']] . "</OPTION>";
                                $options[$option[$column['COLUMN_NAME']]] = true;
                            }
                        }
                        echo '</SELECT>';
                        echo "</TD></TR>";
                    }
                }
                if (count($search_fields_RET['edits'])) {
                    foreach ($search_fields_RET['edits'] as $column) {
                        if ($column['SELECT_OPTIONS']) {
                            $column['SELECT_OPTIONS'] = str_replace("\n", "\r", str_replace("\r\n", "\r", $column['SELECT_OPTIONS']));
                            $options_RET = explode("\r", $column['SELECT_OPTIONS']);
                        } else {
                            $options_RET = array();
                        }
                        echo "<TR><TD align=right width=120>{$column['TITLE']}</TD><TD>";
                        echo "<SELECT name=cust[{$column[COLUMN_NAME]}] style='max-width:250;'><OPTION value=''>" . _('N/A') . "</OPTION><OPTION value='!'>" . _('No Value') . "</OPTION>";
                        $options = array();
                        foreach ($options_RET as $option) {
                            echo "<OPTION value=\"{$option}\">{$option}</OPTION>";
                        }
                        echo "<OPTION value=\"---\">---</OPTION>";
                        echo "<OPTION value=\"~\">" . _('Other Value') . "</OPTION>";
                        echo '</SELECT>';
                        echo "</TD></TR>";
                    }
                }
                if (count($search_fields_RET['date'])) {
                    foreach ($search_fields_RET['date'] as $column) {
                        echo "<TR><TD align=right width=120>{$column['TITLE']}<BR><small>No Value</small><INPUT type=checkbox name=cust_null[{$column['COLUMN_NAME']}]></TD><TD><table cellpadding=0 cellspacing=0><tr><td>&ge;&nbsp;</td><td>" . PrepareDate('', '_cust_begin[' . $column['COLUMN_NAME'] . ']', true, array('short' => true)) . '</td></tr><tr><td>&le;&nbsp;</td><td>' . PrepareDate('', '_cust_end[' . $column['COLUMN_NAME'] . ']', true, array('short' => true)) . "</td></tr></table></TD></TR>";
                    }
                }
                if (count($search_fields_RET['radio'])) {
                    echo "<TR><TD colspan=2><TABLE border=0>";
                    echo "<TR><TD width=120></TD><TD><table border=0 cellpadding=0 cellspacing=0><tr><td width=25><b>" . _('All') . "</b></td><td width=30><b>" . _('Yes') . "</b></td><td width=25><b>" . _('No') . "</b></td></tr></table></TD><TD></TD>";
                    if (count($search_fields_RET['radio']) > 1) {
                        echo "<TD width=120></TD><TD><table border=0 cellpadding=0 cellspacing=0><tr><td width=25><b>" . _('All') . "</b></td><td width=30><b>" . _('Yes') . "</b></td><td width=25><b>" . _('No') . "</b></td></tr></table></TD><TD></TD>";
                    }
                    echo "</TR>";
                    $side = 0;
                    foreach ($search_fields_RET['radio'] as $cust) {
                        if (!$side) {
                            echo '<TR>';
                        }
                        echo "<TD width=120 align=right>{$cust['TITLE']}</TD><TD>\n\t\t\t\t\t\t<table border=0 cellpadding=0 cellspacing=0><tr><td width=25 align=center>\n\t\t\t\t\t\t<input name='cust[{$cust[COLUMN_NAME]}]' type='radio' value='' checked='checked' />\n\t\t\t\t\t\t</td><td width=30 align=center>\n\t\t\t\t\t\t<input name='cust[{$cust[COLUMN_NAME]}]' type='radio' value='Y' />\n\t\t\t\t\t\t</td><td width=25 align=center>\n\t\t\t\t\t\t<input name='cust[{$cust[COLUMN_NAME]}]' type='radio' value='N' />\n\t\t\t\t\t\t</td></tr></table>\n\t\t\t\t\t\t</TD><TD></TD>";
                        if ($side) {
                            echo '</TR>';
                        }
                        $side = 1 - $side;
                    }
                    if ($side) {
                        echo '</TR>';
                    }
                    echo "</TABLE></TD></TR>";
                }
                if ($type == 'student_fields_all' || $type == 'staff_fields_all') {
                    echo '</TABLE>';
                }
            }
            break;
    }
}
Example #6
0
        $extra['extra_header_left'] .= '<TD style="text-align:right; width:20px;">&nbsp;</TD>';
        $extra['extra_header_left'] .= '<TD style="text-align:right; vertical-align:top;">' . _('Other Options') . ':</TD>';
        $extra['extra_header_left'] .= '<TD><TABLE>';
        //modif Francois: add Show Grades option
        $extra['extra_header_left'] .= '<TR><TD><label><INPUT type="checkbox" name="showgrades" value="1" checked /> ' . _('Grades') . '</label></TD></TR>';
        $extra['extra_header_left'] .= '<TR><TD><label><INPUT type="checkbox" name="showstudentpic" value="1"> ' . _('Student Photo') . '</label></TD></TR>';
        //modif Francois: add Show Comments option
        $extra['extra_header_left'] .= '<TR><TD><label><INPUT type="checkbox" name="showmpcomments" value="1"> ' . _('Comments') . '</label></TD></TR>';
        //modif Francois: add Show Credits option
        $extra['extra_header_left'] .= '<TR><TD><label><INPUT type="checkbox" name="showcredits" value="1" checked /> ' . _('Credits') . '</label></TD></TR>';
        //modif Francois: add Show Credit Hours option
        $extra['extra_header_left'] .= '<TR><TD><label><INPUT type="checkbox" name="showcredithours" value="1"> ' . _('Credit Hours') . '</label></TD></TR>';
        //modif Francois: limit Cetificate to admin
        if (User('PROFILE') == 'admin') {
            //modif Francois: add Show Studies Certificate option
            $field_SSECURITY = ParseMLArray(DBGet(DBQuery("SELECT TITLE FROM CUSTOM_FIELDS WHERE ID = 200000003")), 'TITLE');
            $extra['extra_header_left'] .= '<TR><TD><label><INPUT type="checkbox" name="showcertificate" value="1" onclick=\'javascript: document.getElementById("divcertificatetext").style.display="block"; document.getElementById("inputcertificatetext").focus();\'> ' . _('Studies Certificate') . '</label></TD></TR>';
            //modif Francois: add Template
            $templates = DBGet(DBQuery("SELECT TEMPLATE, STAFF_ID FROM TEMPLATES WHERE MODNAME = '" . $_REQUEST['modname'] . "' AND STAFF_ID IN (0,'" . User('STAFF_ID') . "')"), array(), array('STAFF_ID'));
        }
        //$extra['extra_header_left'] .= '<TR><TD><INPUT type=checkbox name=showsat value=1>SAT Scores</TD></TR>';
        $extra['extra_header_left'] .= '</TABLE>';
        $extra['extra_header_left'] .= '</TD><TD></TD></TR></TABLE></TR>';
        $extra['extra_header_left'] .= '</TABLE>';
        //modif Francois: limit Cetificate to admin
        if (User('PROFILE') == 'admin') {
            //modif Francois: add Show Studies Certificate option
            $extra['extra_header_left'] .= '<DIV id="divcertificatetext" style="display:none"><TEXTAREA id="inputcertificatetext" name="inputcertificatetext" cols="100" rows="5">' . str_replace(array("'", '"'), array('&#39;', '&rdquo;', ''), $templates[User('STAFF_ID')] ? $templates[User('STAFF_ID')][1]['TEMPLATE'] : $templates[0][1]['TEMPLATE']) . '</TEXTAREA><BR /><span class="legend-gray">' . str_replace(array("'", '"'), array('&#39;', '\\"'), _('Certificate Studies Text')) . '</span>
			<TABLE><TR><TD style="text-align:right; vertical-align: top;">' . Localize('colon', _('Substitutions')) . '</TD><TD><TABLE><TR>';
            $extra['extra_header_left'] .= '<TD>__SSECURITY__</TD><TD>= ' . str_replace(array("'", '"'), array('&#39;', '\\"'), $field_SSECURITY[1]['TITLE']) . '</TD><TD colspan="3">&nbsp;</TD>';
            $extra['extra_header_left'] .= '</TR><TR>';