<?php

function DrawStudentHeader()
{
    global $_SYSTEM;
    $programs = array('mod_students/Students.php' => _('Student Info'),
        'mod_students/Students.php?category_id=1' => _('Enrollment'),
        'mod_curriculum/Curriculum.php' => _('Schedule'),
        'mod_curriculum/ScdStudReqProperties.php' => _('Requests'),
        'mod_grades/GrdPrintStudGrades.php' => _('Final Grades'),
        'mod_attendance/AttdStuSumAttendance.php' => _('Absences'),
        'mod_activity/ActStudMain.php' => _('Activities'),
//	'mod_evaluation/SuitStudReport.php'=>_('Suitability'),
        'mod_evaluation/SuitIntermediateReport.php' => _('Eligibility'),
        'mod_discipline/DisListSubmittedReports.php' => _('Incident Reports'),
        'mod_billing/BilStudFeesList.php' => _('Fees'),
        'mod_billing/BilStudPaysList.php' => _('Payments'));
    if(!$_SYSTEM['config']['STUDENT_REGISTRATION'])
        unset($programs['mod_students/Students.php?category_id=1']);
    if($_REQUEST['servicemod'] == 'mod_apply/Applicants.php' || substr($_REQUEST['servicemod'],0,10) == 'mod_apply/')
    {
	    unset($programs);
	    $programs = array('mod_apply/Applicants.php' => _('Applicant Info'),
			      'mod_apply/EntryExams.php' => _('Entry Exams'),
			      'mod_apply/AppPrintSpecDocs.php' => _('References')
	    );

    }
    foreach($programs as $servicemod => $title)
    {
        if(AllowUse($servicemod))
        {
            if($servicemod == 'mod_discipline/DisListSubmittedReports.php')
                $links[$servicemod] = 'modloader.php?servicemod='.$servicemod.'&search_servicefunction=list&student_header=true&stuid='.get_student_id().'&student_id='.get_student_id().'&GridOutputCount='.$_REQUEST['GridOutputCount'].'&useontop='.$_REQUEST['useontop'];
            elseif($servicemod == 'mod_students/Students.php?category_id=1')
            {
                $links[$servicemod] = 'modloader.php?servicemod=mod_students/Students.php&include=Enrollment&historical=Y&GridOutputCount='.$_REQUEST['GridOutputCount'].'&useontop='.$_REQUEST['useontop'];
                $default_selected = $links[$servicemod];
            }
            else
                $links[$servicemod] = 'modloader.php?servicemod='.$servicemod.'&GridOutputCount='.$_REQUEST['GridOutputCount'].'&useontop='.$_REQUEST['useontop'];
        }
        else
            unset($programs[$servicemod]);
    }
    if(isset($_REQUEST['GridOutputCount']))
    {
        $tmp_REQUEST = $_REQUEST;
        unset($tmp_REQUEST['GridOutputCount']);
        unset($tmp_REQUEST['values']);
        unset($tmp_REQUEST['address_id']);
        unset($tmp_REQUEST['person_id']);
        unset($tmp_REQUEST['student_id']);
        unset($tmp_REQUEST['discipline_ir_id']);
        // search_servicefunction can probably be unset in any case
        //if($tmp_REQUEST['search_servicefunction']=='result')
        unset($tmp_REQUEST['search_servicefunction']);

        // since we need this for the referrals screen
        unset($tmp_REQUEST['stuid']);
        // since GrdPrintStudGrades has issues with the MP tabs ... this probably applies to any program, but why chance it...
        if($_REQUEST['servicemod'] == 'mod_grades/GrdPrintStudGrades.php')
            unset($tmp_REQUEST['search_servicefunction']);
        $right = '<TABLE cellspacing=2><TR>';
        if($_REQUEST['GridOutputCount'] > 1)
        {
            if($_SYSTEM['direction'] == 'RTL')
                $right .= '<TD><A HREF='.SetRequestOptions($tmp_REQUEST).'&GridOutputCount='.($_REQUEST['GridOutputCount'] - 1).'><IMG SRC=images/arrow_right.gif border=0></A></TD>';
            else
                $right .= '<TD><A HREF='.SetRequestOptions($tmp_REQUEST).'&GridOutputCount='.($_REQUEST['GridOutputCount'] - 1).'><IMG SRC=images/arrow_left.gif border=0></A></TD>';
        }
        $right .= '<TD>'.button('dot', 'C9C9C9', '', '8').'</TD>';
        if($_SESSION['student_list'] && ($_REQUEST['GridOutputCount'] < count($_SESSION['student_list'])))
        {
            if($_SYSTEM['direction'] == 'RTL')
                $right .= '<TD><A HREF='.SetRequestOptions($tmp_REQUEST).'&GridOutputCount='.((int)$_REQUEST['GridOutputCount'] + 1).'><IMG SRC=images/arrow_left.gif border=0></A></TD>';
            else
                $right .= '<TD><A HREF='.SetRequestOptions($tmp_REQUEST).'&GridOutputCount='.((int)$_REQUEST['GridOutputCount'] + 1).'><IMG SRC=images/arrow_right.gif border=0></A></TD>';
        }
        $right .= '</TR></TABLE>';
    }
    else
        unset($_SESSION['student_list']);


    if(!$_REQUEST['CREATEPDF'] && (get_user('PROFILE') == 'admin' || get_user('PROFILE') == 'teacher')){
        WrapRoundedTabs($programs, $links, 'left', null, $right, null, $default_selected);
    }elseif(get_student_id() && $_REQUEST['CREATEPDF']){
        $array = db_request(db_execute("SELECT FIRST_NAME,LAST_NAME,MIDDLE_NAME,NAME_SUFFIX FROM STUDENTS WHERE STUDENT_ID='".get_student_id()."'"));
        echo DisplayHeader($array[1]['FIRST_NAME'].'&nbsp;'.($array[1]['MIDDLE_NAME'] ? $array[1]['MIDDLE_NAME'].' ' : '').$array[1]['LAST_NAME'].'&nbsp;'.$array[1]['NAME_SUFFIX']);
    }
}

function DrawUserHeader($header='')
{
    global $_SYSTEM;
    $programs = array();

    if(isset($_SESSION['GridOutputCount'])){
        $tmp_REQUEST = $_REQUEST;
        unset($tmp_REQUEST['GridOutputCount']);
        unset($tmp_REQUEST['values']);
        unset($tmp_REQUEST['address_id']);
        unset($tmp_REQUEST['person_id']);
        unset($tmp_REQUEST['student_id']);
        unset($tmp_REQUEST['user_id']);
        unset($tmp_REQUEST['discipline_ir_id']);
        unset($tmp_REQUEST['users_search_servicefunction']);
        $right = '<TABLE cellspacing=2><TR>';
        if($_SESSION['GridOutputCount'] > 1){
            if($_SYSTEM['direction'] == 'RTL')
                $right .= '<TD><A HREF='.SetRequestOptions($tmp_REQUEST).'&GridOutputCount='.($_SESSION['GridOutputCount'] - 1).'><IMG SRC=images/arrow_right.gif border=0></A></TD>';
            else
                $right .= '<TD><A HREF='.SetRequestOptions($tmp_REQUEST).'&GridOutputCount='.($_SESSION['GridOutputCount'] - 1).'><IMG SRC=images/arrow_left.gif border=0></A></TD>';
        }
//		$right .= '<TD>'.button('dot','C9C9C9','','8').'</TD>';
        $right .= '<TD><B>'._('Teachers').'</B></TD>';
        if($_SESSION['GridOutputCount'] < count($_SESSION['user_list'])){
            if($_SYSTEM['direction'] == 'RTL')
                $right .= '<TD><A HREF='.SetRequestOptions($tmp_REQUEST).'&GridOutputCount='.($_SESSION['GridOutputCount'] + 1).'><IMG SRC=images/arrow_left.gif border=0></A></TD>';
            else
                $right .= '<TD><A HREF='.SetRequestOptions($tmp_REQUEST).'&GridOutputCount='.($_SESSION['GridOutputCount'] + 1).'><IMG SRC=images/arrow_right.gif border=0></A></TD>';
        }
        $right .= '</TR></TABLE>';
    }
    else
        unset($_SESSION['user_list']);

    $_REQUEST['DrawAlign'] = 'CENTER';
    if(!$_REQUEST['CREATEPDF'] && (get_user('PROFILE') == 'admin' || get_user('PROFILE') == 'teacher'))
        echo DisplayHeader(_('Select a class').' '.$header.$right);
    elseif(get_user_id() && $_REQUEST['CREATEPDF']){
        $array = db_request(db_execute("SELECT FIRST_NAME,LAST_NAME,MIDDLE_NAME FROM USERS WHERE USER_ID='".get_user_id()."'"));
        echo DisplayHeader($array[1]['FIRST_NAME'].'&nbsp;'.($array[1]['MIDDLE_NAME'] ? $array[1]['MIDDLE_NAME'].' ' : '').$array[1]['LAST_NAME']);
    }
}
?>