Skip to content

Commit

Permalink
Fix regression since 5.0, allow Administration of "Lunch" attendance …
Browse files Browse the repository at this point in the history
…categories
  • Loading branch information
francoisjacquet committed May 24, 2022
1 parent b226e16 commit 18a3776
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -92,6 +92,7 @@ Changes in 9.0
- JS Sanitize string for legal variable name in Export.php & Inputs.php
- Remove deprecated `_makeTeacher()` function in ReportCards.fnc.php
- Use multiple select input for grades list to gain space in Widget.php
- Fix regression since 5.0, allow Administration of "Lunch" attendance categories in Administration.php, AttendanceCodes.fnc.php & colors.css

Changes in 8.9.6
----------------
Expand Down
10 changes: 6 additions & 4 deletions assets/themes/FlatSIS/css/colors.css
Expand Up @@ -479,36 +479,38 @@ hr {

/* Attendance Codes */

.attendance-code {
color: #fff;
}

.attendance-code.present {
color: #fff;
background-color: #20DD30;
/* Green */
}

.attendance-code.absent {
color: #fff;
background-color: #FF0000;
/* Red */
}

.attendance-code.half-day {
color: #fff;
background-color: #FFCC00;
/* Yellow */
}

.attendance-code.present-alt {
color: #fff;
background-color: #DDFFDD;
/* Green */
}

.attendance-code.absent-alt {
color: #fff;
background-color: #FFDDDD;
/* Red */
}

.attendance-code.half-day-alt {
color: #fff;
background-color: #FFEEDD;
/* Yellow */
}
Expand Down
2 changes: 1 addition & 1 deletion assets/themes/FlatSIS/stylesheet.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/themes/FlatSIS/stylesheet_wkhtmltopdf.css

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions assets/themes/WPadmin/css/colors.css
Expand Up @@ -425,36 +425,38 @@ hr {

/* Attendance Codes */

.attendance-code {
color: #fff;
}

.attendance-code.present {
color: #fff;
background-color: #20DD30;
/* Green */
}

.attendance-code.absent {
color: #fff;
background-color: #FF0000;
/* Red */
}

.attendance-code.half-day {
color: #fff;
background-color: #FFCC00;
/* Yellow */
}

.attendance-code.present-alt {
color: #fff;
background-color: #DDFFDD;
/* Green */
}

.attendance-code.absent-alt {
color: #fff;
background-color: #FFDDDD;
/* Red */
}

.attendance-code.half-day-alt {
color: #fff;
background-color: #FFEEDD;
/* Yellow */
}
Expand Down
2 changes: 1 addition & 1 deletion assets/themes/WPadmin/stylesheet.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/themes/WPadmin/stylesheet_wkhtmltopdf.css

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion modules/Attendance/Administration.php
Expand Up @@ -516,7 +516,13 @@
_( 'Current Student' ) . '</a></td><td>';
}

$headerl = AttendanceCodesTipMessage();
if ( $headerl )
{
// Header already has Attendance categories: add spacing.
$headerl .= ' &mdash; ';
}

$headerl .= AttendanceCodesTipMessage( '', $_REQUEST['table'] );

$headerr = '<table style="float: right;"><tr><td class="align-right">' .
button(
Expand Down
24 changes: 12 additions & 12 deletions modules/Attendance/includes/AttendanceCodes.fnc.php
Expand Up @@ -9,9 +9,10 @@
/**
* Make Attendance Code
*
* @todo use in TakeAttendance & oher reports than DailySummary.php.
* @todo use in TakeAttendance & other reports than DailySummary.php.
*
* @since 3.8
* @since 9.0 Allow empty State code.
*
* @param array $state_code Attendance State code.
* @param string $name Name or HTML to display. Defaults to localized attendance code.
Expand All @@ -21,11 +22,6 @@
*/
function MakeAttendanceCode( $state_code, $name = '', $title = '' )
{
if ( empty( $state_code ) )
{
return '';
}

$attendance_codes_locale = [
// Attendance codes.
'P' => _( 'Present' ),
Expand Down Expand Up @@ -58,12 +54,15 @@ function MakeAttendanceCode( $state_code, $name = '', $title = '' )
$state_code = '0.5';
}

if ( $title === '' )
if ( $state_code )
{
$title = $attendance_codes_locale[ $state_code ];
}
if ( $title === '' )
{
$title = $attendance_codes_locale[ $state_code ];
}

$class .= ' ' . $attendance_code_classes[ $state_code ];
$class .= ' ' . $attendance_code_classes[ $state_code ];
}

if ( $name === '' )
{
Expand All @@ -82,6 +81,7 @@ function MakeAttendanceCode( $state_code, $name = '', $title = '' )
* @since 3.8
*
* @since 3.9 Added $type param.
* @since 9.0 Added $table param.
*
* @uses MakeAttendanceCode
* @uses MakeTipMessage
Expand All @@ -90,7 +90,7 @@ function MakeAttendanceCode( $state_code, $name = '', $title = '' )
*
* @return string Attendance Codes Tip Message.
*/
function AttendanceCodesTipMessage( $type = '' )
function AttendanceCodesTipMessage( $type = '', $table = '0' )
{
static $attendance_codes_RET;

Expand All @@ -112,7 +112,7 @@ function AttendanceCodesTipMessage( $type = '' )
FROM ATTENDANCE_CODES
WHERE SYEAR='" . UserSyear() . "'
AND SCHOOL_ID='" . UserSchool() . "'
AND TABLE_NAME='0'" .
AND TABLE_NAME='" . (int) $table . "'" .
$type_where .
" ORDER BY TABLE_NAME,SORT_ORDER" );
}
Expand Down

0 comments on commit 18a3776

Please sign in to comment.