#! /usr/bin/perl # Copyright 2001-2007 Leslie Richardson # This file is part of Open Admin for Schools. # Open Admin for Schools is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # Outline: 1) Get passed variables for start date, end date and withdrawn students # 2) Read each student from student table (ordered by homeroom/grade,lastname, # firstname), and check for matching records in the attend table. # 3) If no records, print perfect attendance report. # Updated: (March/06): Display withdrawn students and allow to print # selected profiles for those students. Also add subject specific # printing where there is subject based attendance. use DBI; use CGI; use Date::Business; my %lex = ('Attendance Profiles' => 'Attendance Profiles', 'Missing Start Date or End Date' => 'Missing Start Date or End Date', 'Attendance' => 'Attendance', 'Cannot open tex file' => 'Cannot open tex file', 'Enrollment Changes' => 'Enrollment Changes', 'Error: Missing grade for student' => 'Error: Missing grade for student', 'Periods Per Day not defined for Grade' => 'Periods Per Day not defined for Grade', 'in global configuration for student' => 'in global configuration for student', 'Perfect Attendance!' => 'Perfect Attendance!', 'View/Download' => 'View/Download', 'View Log File' => 'View Log File', 'Total' => 'Total', 'Absent' => 'Absent', 'Late' => 'Late', 'Excused' => 'Excused', 'Unexcused' => 'Unexcused', 'times' => 'times', 'day(s)' => 'day(s)', 'Main' => 'Main', 'Name' => 'Name', 'Select' => 'Select', 'Withdrawn Students' => 'Withdrawn Students', 'Date format Error' => 'Date format Error', 'Subject' => 'Subject', 'Lastname, Firstname' => 'Lastname, Firstname', 'Homeroom, Lastname, Firstname' => 'Homeroom, Lastname, Firstname', 'Grade, Lastname, Firstname' => 'Grade, Lastname, Firstname', 'Sort by' => 'Sort by', 'Select' => 'Select', 'Grade' => 'Grade', 'Homeroom' => 'Homeroom', 'Start Date' => 'Start Date', 'End Date' => 'End Date', 'Show' => 'Show', 'Continue' => 'Continue', 'No Students Found' => 'No Students Found', 'School Days' => 'School Days', 'Unknown reason' => 'Unknown reason', 'Period' => 'Period', ); my $self = "rptattprof.pl"; unless (require "../etc/admin.conf"){ print "Cannot read admin.conf!"; die "Cannot read admin.conf!"; } my $maxlines = 28; my $shortname = "attprofile$$"; my $filename = "$shortname.tex"; # Set AM/PM Hash for use converting 2 period day to AM/PM %ampm = ( 1 => 'AM', 2 => 'PM'); my $dsn = "DBI:$dbtype:dbname=$dbase"; my $dbh = DBI->connect($dsn,$user,$password); my @month = ('','January','February','March','April','May','June', 'July','August','September','October','November','December'); my $q = new CGI; print $q->header; my %arr = $q->Vars; my $wdselectflag; if ( $arr{wdselectflag} ) { # We have selected withdrawn students to print. $wdselectflag = 1; delete $arr{wdselectflag}; } my $sortorder = "homeroom, lastname, firstname"; if ( $arr{sortorder} eq $lex{'Lastname, Firstname'} ) { $sortorder = "lastname, firstname"; } elsif ( $arr{sortorder} eq $lex{'Grade, Lastname, Firstname'} ) { $sortorder = "grade,lastname, firstname"; } elsif ( $arr{sortorder} eq $lex{'Homeroom, Lastname, Firstname'} ) { $sortorder = "homeroom, lastname, firstname"; } if ( $arr{sortorder} ) { delete $arr{sortorder}; } my $select; if ( $arr{group} ) { if ( $arr{select} eq $lex{Grade} ) { # Find this grade; my $grp = $dbh->quote( $arr{group} ); $select = "where grade = $grp"; } elsif ( $arr{select} eq $lex{Homeroom} ) { my $grp = $dbh->quote( $arr{group} ); $select = "where homeroom = $grp"; } } # print page header print "$doctype\n