#!/usr/bin/perl # Copyright 2001-2008 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 = ('Teacher Attendance Check' => 'Teacher Attendance Check', 'Main' => 'Main', 'Attendance' => 'Attendance', 'Not Found' => 'Not Found', 'Date' => 'Date', 'Name' => 'Name', 'Date/Time' => 'Date/Time', 'Error' => 'Error', 'Zero times represent entries from other days' => 'Zero times represent entries from other days', ); use DBI; use CGI; my $q = new CGI; print $q->header; %arr = $q->Vars; my $currdate; if (not $arr{date}) { my @tim = localtime(time); my $year = @tim[5] + 1900; my $month = @tim[4] + 1; my $day = @tim[3]; $currdate = "$year-$month-$day"; } else { $currdate = $arr{date}; } # Read config variables eval require "../etc/admin.conf"; if ( $@ ) { print $lex{Error}. " $@
\n"; die $lex{Error}. " $@\n"; } my $dsn = "DBI:$dbtype:dbname=$dbase"; my $dbh = DBI->connect($dsn,$user,$password); my $sth = $dbh->prepare("select lastname, firstname, userid from staff where doatt = 'Y' order by lastname, firstname"); $sth->execute; if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr; } my $records = $sth->rows; print "$doctype\n". $lex{'Teacher Attendance Check'}. " $chartype\n[ ". $lex{Main}. " | ". $lex{Attendance}. " ]

". $lex{'Teacher Attendance Check'}. "

\n"; print "
". $lex{Date}. ": $currdate
"; print $lex{'Zero times represent entries from other days'}. "
\n"; print "\n"; for (1..$records) { # Do one teacher after the other... my ($lastname, $firstname, $userid) = $sth->fetchrow; $sth1 = $dbh->prepare("select * from tattend where techid = ? and to_days(date) = to_days('$currdate')"); $sth1->execute( $userid ) ; if ($DBI::errstr) { print $DBI::errstr; die $DBI::errstr;} my $rows = $sth1->rows; if ($rows < 1) { print ""; print '\n"; } else { for (1..$rows) { my ($id, $userid, $tdate) = $sth1->fetchrow; print ""; print "\n"; } } print "\n"; } print "
", $lex{Name}. ''. $lex{'Date/Time'}. "
$firstname $lastname',$lex{'Not Found'}. "
$firstname $lastname$tdate
"; print "
\n";