136 lines
4.4 KiB
PHP
136 lines
4.4 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
//
|
|
// Process all actions to list and edit records
|
|
//
|
|
$CurrentTable = "classes";
|
|
$TitleText = getLanguageText('TEXT-CLASS');
|
|
$OrderBy = "sequence,grade";
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = $GlobalText['ClassAdministration'];
|
|
|
|
|
|
$school_num = $school_record['record_num'];
|
|
|
|
|
|
//
|
|
// List all records
|
|
//
|
|
|
|
|
|
// Determine if there are any class_programs defined
|
|
$num_programs = db_getVal("select count(*) from class_programs where school_num = $school_num");
|
|
|
|
// Determine if there are any class_programs in use
|
|
$programs_in_use = 0;
|
|
if ($num_programs > 0) {
|
|
$programs_in_use = db_getVal("select count(*) from classes where school_num = $school_num and class_program is not NULL");
|
|
}
|
|
|
|
|
|
// Initialize the select clause
|
|
$select = "";
|
|
$group_by = "";
|
|
$columnHeaders = array();
|
|
$columnAlign = array();
|
|
|
|
$TableWidth = 550;
|
|
|
|
// Build select and headers array
|
|
$numEntries = db_getVal("SELECT count(*) FROM classes WHERE school_num = $school_num AND division > '' AND division IS NOT NULL");
|
|
if ($school_record['i_display_division'] == 'Y' && $numEntries > 0) {
|
|
if (strlen($select) > 0) $select .= ",";
|
|
$select .= "division";
|
|
if (strlen($group_by) > 0) $group_by .= ",";
|
|
$group_by .= "division";
|
|
$columnHeaders[] = getLanguageText('TEXT-CLASS');
|
|
$columnAlign[] = 'center';
|
|
}
|
|
|
|
if ($programs_in_use > 0) {
|
|
if (strlen($select) > 0) $select .= ",";
|
|
$select .= "cp.program_name";
|
|
if (strlen($group_by) > 0) $group_by .= ",";
|
|
$group_by .= "program_name";
|
|
$columnHeaders[] = getLanguageText('TEXT-PROGRAM');
|
|
$columnAlign[] = 'left';
|
|
$TableWidth += 75;
|
|
}
|
|
|
|
$numEntries = db_getVal("SELECT count(*) FROM classes WHERE school_num = $school_num AND grade > '' AND grade IS NOT NULL");
|
|
if ($school_record['p_display_grade'] == 'Y' && $numEntries > 0) {
|
|
if (strlen($select) > 0) $select .= ",";
|
|
$select .= "c.grade";
|
|
if (strlen($group_by) > 0) $group_by .= ",";
|
|
$group_by .= "c.grade";
|
|
$columnHeaders[] = getLanguageText('TEXT-GRADE');
|
|
$columnAlign[] = 'center';
|
|
}
|
|
|
|
$numEntries = db_getVal("SELECT count(*) FROM classes WHERE school_num = $school_num AND description > '' AND description IS NOT NULL");
|
|
if ($school_record['p_display_description'] == 'Y' && $numEntries > 0) {
|
|
if (strlen($select) > 0) $select .= ",";
|
|
$select .= "description";
|
|
if (strlen($group_by) > 0) $group_by .= ",";
|
|
$group_by .= "description";
|
|
$columnHeaders[] = getLanguageText('TEXT-DESCRIPTION');
|
|
$columnAlign[] = 'left';
|
|
$TableWidth += 75;
|
|
}
|
|
|
|
if (strlen($select) > 0) $select .= ",";
|
|
$select .= "concat_ws(' ',p1.title,p1.first_name,p1.last_name) as t1,concat_ws(' ',p2.title,p2.first_name,p2.last_name) as t2";
|
|
if (strlen($group_by) > 0) $group_by .= ",";
|
|
$group_by .= "t1,t2,c.record_num";
|
|
|
|
|
|
$numFirstTeachers = db_getVal("SELECT count(*) FROM classes WHERE school_num = $school_num AND teacher1 > '' AND teacher1 IS NOT NULL");
|
|
if ($numFirstTeachers > 0) {
|
|
$columnHeaders[] = getLanguageText('TEXT-TEACHER');
|
|
$columnAlign[] = 'left';
|
|
}
|
|
|
|
// Append additional "Teacher" column to header array if required (maximum 2 teachers listed)
|
|
$numSecondTeachers = db_getVal("SELECT count(*) FROM classes WHERE school_num = $school_num AND teacher2 > '' AND teacher2 IS NOT NULL");
|
|
if ($numSecondTeachers > 0) {
|
|
$columnHeaders[] = getLanguageText('TEXT-TEACHER');
|
|
$columnAlign[] = 'left';
|
|
$TableWidth += 75;
|
|
}
|
|
|
|
$query = "SELECT $select,c.record_num " .
|
|
"FROM classes as c LEFT JOIN people as p1 on c.teacher1 = p1.record_num " .
|
|
"LEFT JOIN people as p2 on c.teacher2 = p2.record_num and c.display_teacher2 = 'Y' " .
|
|
"LEFT JOIN class_programs as cp on class_program = cp.record_num " .
|
|
"WHERE c.school_num = $school_num " .
|
|
"AND entry_type = 'Class' " .
|
|
"ORDER BY c.sequence";
|
|
$results = db_query($query);
|
|
|
|
|
|
$message_width = $default_data_width;
|
|
include "form.messages.php";
|
|
|
|
$print_icon = "<img src='images/icons/printer24.png' alt='Print Class Contact' border='0'>";
|
|
|
|
$commands = array(
|
|
"<a href='/class-list.print.php?class_num=%d' title='Class Contact List'>$print_icon</a>"
|
|
);
|
|
|
|
listDataCustom($results,$columnHeaders,$action,$commands,'Y',$columnAlign);
|
|
|
|
echo("</center>\n");
|
|
|
|
|
|
endTemplate();
|
|
?>
|