TeacherCompletion.php 4.81 KB
Newer Older
François Jacquet's avatar
François Jacquet committed
1
<?php
2 3
require_once 'ProgramFunctions/TipMessage.fnc.php';

François Jacquet's avatar
François Jacquet committed
4 5
$_REQUEST['period'] = issetVal( $_REQUEST['period'] );

6 7
DrawHeader( ProgramTitle() );

8 9
// GET ALL THE CONFIG ITEMS FOR ELIGIBILITY
$eligibility_config = ProgramConfig( 'eligibility' );
François Jacquet's avatar
François Jacquet committed
10

11
foreach ( (array) $eligibility_config as $value )
François Jacquet's avatar
François Jacquet committed
12
{
13
	${$value[1]['TITLE']} = $value[1]['VALUE'];
François Jacquet's avatar
François Jacquet committed
14 15
}

16 17
// Day of the week: 1 (for Monday) through 7 (for Sunday).
$today = date( 'w' ) ? date( 'w' ) : 7;
François Jacquet's avatar
François Jacquet committed
18

François Jacquet's avatar
François Jacquet committed
19
$start = time() - ( $today - $START_DAY ) * 60 * 60 * 24;
François Jacquet's avatar
François Jacquet committed
20

21
if ( empty( $_REQUEST['start_date'] ) )
François Jacquet's avatar
François Jacquet committed
22 23
{
	$start_time = $start;
24

François Jacquet's avatar
François Jacquet committed
25
	$start_date = date( 'Y-m-d', $start_time );
26

François Jacquet's avatar
François Jacquet committed
27
	$end_date = date( 'Y-m-d' );
François Jacquet's avatar
François Jacquet committed
28 29 30 31
}
else
{
	$start_time = $_REQUEST['start_date'];
32

François Jacquet's avatar
François Jacquet committed
33
	$start_date = date( 'Y-m-d', $start_time );
34

François Jacquet's avatar
François Jacquet committed
35
	$end_date = date( 'Y-m-d', $start_time + 60 * 60 * 24 * 7 );
François Jacquet's avatar
François Jacquet committed
36 37
}

38
$periods_RET = DBGet( "SELECT PERIOD_ID,TITLE
39 40 41
	FROM SCHOOL_PERIODS
	WHERE SCHOOL_ID='" . UserSchool() . "'
	AND SYEAR='" . UserSyear() . "'
42
	ORDER BY SORT_ORDER" );
43

François Jacquet's avatar
François Jacquet committed
44 45
$period_select = '<select name="period"><option value="">' . _( 'All' ) . '</option>';

46 47 48 49 50 51 52
foreach ( (array) $periods_RET as $period )
{
	$period_select .= '<option value="' . $period['PERIOD_ID'] . '"' .
		( $_REQUEST['period'] == $period['PERIOD_ID'] ? ' selected' : '' ) . '>' .
		$period['TITLE'] . '</option>';
}

François Jacquet's avatar
François Jacquet committed
53
$period_select .= '</select>';
François Jacquet's avatar
François Jacquet committed
54

55
echo '<form action="' . URLEscape( 'Modules.php?modname=' . $_REQUEST['modname']  ) . '" method="GET">';
56

57
$begin_year = DBGetOne( "SELECT min(date_part('epoch',SCHOOL_DATE)) AS SCHOOL_DATE
58 59
	FROM ATTENDANCE_CALENDAR
	WHERE SCHOOL_ID='" . UserSchool() . "'
60
	AND SYEAR='" . UserSyear() . "'" );
François Jacquet's avatar
François Jacquet committed
61

62 63
if ( $start
	&& $begin_year )
François Jacquet's avatar
François Jacquet committed
64
{
65
	$date_select = '<option value="' . $start . '">' .
François Jacquet's avatar
François Jacquet committed
66
	ProperDate( date( 'Y-m-d', $start ) ) . ' - ' . ProperDate( DBDate() ) . '</option>';
67

François Jacquet's avatar
François Jacquet committed
68
	for ( $i = $start - ( 60 * 60 * 24 * 7 ); $i >= $begin_year; $i -= ( 60 * 60 * 24 * 7 ) )
69 70
	{
		$date_select .= '<option value="' . $i . '"' .
François Jacquet's avatar
François Jacquet committed
71 72 73
		(  ( $i + 86400 >= $start_time && $i - 86400 <= $start_time ) ? ' selected' : '' ) . '>' .
		ProperDate( date( 'Y-m-d', $i ) ) . ' - ' .
		ProperDate( date( 'Y-m-d', ( $i + 1 + (  ( $END_DAY - $START_DAY ) ) * 60 * 60 * 24 ) ) ) . '</option>';
74
	}
François Jacquet's avatar
François Jacquet committed
75 76
}

François Jacquet's avatar
François Jacquet committed
77
DrawHeader( _( 'Timeframe' ) . ': <select name="start_date">' . $date_select . '</select> &mdash; ' .
78 79
	_( 'Period' ) . ': ' . $period_select . ' ' . SubmitButton( _( 'Go' ) ) );

François Jacquet's avatar
François Jacquet committed
80
echo '</form>';
François Jacquet's avatar
François Jacquet committed
81

François Jacquet's avatar
François Jacquet committed
82
//FJ multiple school periods for a course period
83
/*$sql = "SELECT s.LAST_NAME||', '||s.FIRST_NAME AS FULL_NAME,sp.TITLE,cp.PERIOD_ID,s.STAFF_ID
François Jacquet's avatar
François Jacquet committed
84 85 86 87 88 89 90 91
FROM STAFF s,COURSE_PERIODS cp,SCHOOL_PERIODS sp
WHERE
sp.PERIOD_ID = cp.PERIOD_ID
AND cp.TEACHER_ID=s.STAFF_ID AND cp.MARKING_PERIOD_ID IN (".GetAllMP('QTR',UserMP()).")
AND cp.SYEAR='".UserSyear()."' AND cp.SCHOOL_ID='".UserSchool()."' AND s.PROFILE='teacher'
".(($_REQUEST['period'])?" AND cp.PERIOD_ID='".$_REQUEST['period']."'":'')."
AND NOT EXISTS (SELECT '' FROM ELIGIBILITY_COMPLETED ac WHERE ac.STAFF_ID=cp.TEACHER_ID AND ac.PERIOD_ID = sp.PERIOD_ID AND ac.SCHOOL_DATE BETWEEN '".$start_date."' AND '".$end_date."')
";*/
92
$sql = "SELECT " . DisplayNameSQL( 's' ) . " AS FULL_NAME,sp.TITLE,cpsp.PERIOD_ID,
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
	s.STAFF_ID,cp.TITLE AS CP_TITLE
	FROM STAFF s,COURSE_PERIODS cp,SCHOOL_PERIODS sp,COURSE_PERIOD_SCHOOL_PERIODS cpsp
	WHERE cp.COURSE_PERIOD_ID=cpsp.COURSE_PERIOD_ID
	AND sp.PERIOD_ID=cpsp.PERIOD_ID
	AND cp.TEACHER_ID=s.STAFF_ID
	AND cp.MARKING_PERIOD_ID IN (" . GetAllMP( 'QTR', GetCurrentMP( 'QTR', $start_date ) ) . ")
	AND cp.SYEAR='" . UserSyear() . "'
	AND cp.SCHOOL_ID='" . UserSchool() . "'
	AND s.PROFILE='teacher'" .
	( $_REQUEST['period'] ? " AND cpsp.PERIOD_ID='" . $_REQUEST['period'] . "'" : '' ) .
	"AND NOT EXISTS (SELECT ''
		FROM ELIGIBILITY_COMPLETED ac
		WHERE ac.STAFF_ID=cp.TEACHER_ID
		AND ac.PERIOD_ID=sp.PERIOD_ID
		AND ac.SCHOOL_DATE BETWEEN '" . $start_date . "' AND '" . $end_date . "')";

109
$RET = DBGet( $sql, array(), array( 'STAFF_ID', 'PERIOD_ID' ) );
François Jacquet's avatar
François Jacquet committed
110 111

$i = 0;
112

François Jacquet's avatar
François Jacquet committed
113 114
$staff_RET = array();

115
foreach ( (array) $RET as $staff_id => $periods )
François Jacquet's avatar
François Jacquet committed
116
{
117
	$i++;
François Jacquet's avatar
François Jacquet committed
118
	$staff_RET[$i]['FULL_NAME'] = $periods[key( $periods )][1]['FULL_NAME'];
119

120
	if ( empty( $_REQUEST['period'] ) )
François Jacquet's avatar
François Jacquet committed
121
	{
122 123 124 125
		foreach ( (array) $periods as $period_id => $course_periods )
		{
			if ( isset( $_REQUEST['_ROSARIO_PDF'] ) )
			{
François Jacquet's avatar
François Jacquet committed
126
				$staff_RET[$i][$period_id] = _( 'No' );
127 128 129 130 131 132 133 134 135 136 137

				continue;
			}

			$cp_titles = array();

			foreach ( (array) $course_periods as $course_period )
			{
				$cp_titles[] = $course_period['CP_TITLE'];
			}

François Jacquet's avatar
François Jacquet committed
138 139 140 141
			$staff_RET[$i][$period_id] = MakeTipMessage(
				implode( '<br /><br />', $cp_titles ),
				_( 'Course Periods' ),
				button( 'x' )
142 143
			);
		}
François Jacquet's avatar
François Jacquet committed
144 145
	}
}
146 147 148

$columns = array( 'FULL_NAME' => _( 'Teacher' ) );

149
if ( empty( $_REQUEST['period'] ) )
François Jacquet's avatar
François Jacquet committed
150
{
151 152
	foreach ( (array) $periods_RET as $period )
	{
François Jacquet's avatar
François Jacquet committed
153
		$columns[$period['PERIOD_ID']] = $period['TITLE'];
154
	}
François Jacquet's avatar
François Jacquet committed
155 156
}

157 158 159 160 161 162
ListOutput(
	$staff_RET,
	$columns,
	'Teacher who hasn\'t entered eligibility',
	'Teachers who haven\'t entered eligibility'
);