#!/usr/bin/perl # Copyright 2001-2006 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. my %lex = ('Check Student Attendance' => 'Check Student Attendance', 'Main' => 'Main', 'Attendance' => 'Attendance', 'Attendance Check' => 'Attendance Check', 'Name' => 'Name', 'Days' => 'Days', 'HRoom' => 'HRoom', 'Grade' => 'Grade', 'Start' => 'Start', 'End' => 'End', 'Periods Per Day or Grade not correctly set for' => 'Periods Per Day or Grade not correctly set for', ); use DBI; use CGI; # This script looks for student attendance records with a reason field # containing "Absent Unexcused". If you change the reason types, this # script won't work. Change the value of the variable below. my $absreason = "Absent Unexcused"; my @month = ('January','February','March','April','May','June','July', 'August','September','October','November','December'); my @dow = ('Sunday','Monday','Tuesday','Wednesday','Thursday', 'Friday','Saturday'); my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $iddst) = localtime(time); $year = $year + 1900; my $currdate = "$dow[$wday], $month[$mon] $mday, $year"; my $q = new CGI; print $q->header; my %arr = $q->Vars; # Passed in days to start flagging at my $days = $arr{days}; my $startdate = $month[substr($arr{startdate},2,2)-1]." ".substr($arr{startdate},4,2).", 20".substr($arr{startdate},0,2); my $enddate = $month[substr($arr{enddate},2,2)-1]." ".substr($arr{enddate},4,2).", 20".substr($arr{enddate},0,2); # Read config variables do "../etc/admin.conf" || die "Cannot read admin.conf!"; $dsn = "DBI:$dbtype:dbname=$dbase"; $dbh = DBI->connect($dsn,$user,$password); $select = ""; if ($arr{startdate}) { $select = "and to_days(attend.absdate) >= to_days('$arr{startdate}')". " and to_days(attend.absdate) <= to_days('$arr{enddate}')"; } my $sth = $dbh->prepare("select student.studnum, count(*) as missed, student.firstname, student.lastname, student.homeroom, student.grade from attend, student where attend.studentid = student.studnum and attend.reason = '$absreason' $select group by attend.studentid order by missed desc, student.lastname, student.firstname"); $sth->execute; if ($DBI::errstr) { print $DBI::errstr; die $DBI::errstr; } $rows = $sth->rows; print "$doctype\n
| '. $lex{Name}. ' | '. $lex{Days}. ' | '. $lex{HRoom}; print ' | '. $lex{Grade}. " |
|---|---|---|---|
| $arr[3], $arr[2] | $absent | "; print "$arr[4] | $arr[5] |