#!/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. my %lex = ( 'Update Record' => 'Update Record', 'Edit Attendance' => 'Edit Attendance', 'Student Number' => 'Student Number', 'Date' => 'Date', 'Reason' => 'Reason', 'Attendance' => 'Attendance', 'Your attendance update is now stored' => 'Your attendance update is now stored', 'There was an error storing your data' => 'There was an error storing your data', 'Please contact your network administrator at' => 'Please contact your network administrator at', 'Please record the following error string' => 'Please record the following error string', 'Edit/Delete Another Record' => 'Edit/Delete Another Record', 'Today' => 'Today', 'Yesterday' => 'Yesterday', 'All' => 'All', 'Period' => 'Period', 'Subject-Section' => 'Subject-Section', 'min' => 'min', 'Late' => 'Late', 'Main' => 'Main', ); my $self = 'atted.pl'; use DBI; use CGI; my $q = new CGI; print $q->header; my %arr = $q->Vars; require "../etc/admin.conf" or die "Cannot open admin.conf!"; my $dsn = "DBI:$dbtype:dbname=$dbase"; my $dbh = DBI->connect($dsn,$user,$password); my $name = $arr{name}; my $sth = $dbh->prepare("select * from attend where attid = '$arr{recnum}'"); $sth->execute; if ($DBI::errstr) { print $DBI::errstr; die $DBI::errstr; } my ($attid, $studnum, $absdate, $reason, $period, $subjsec, $late) = $sth->fetchrow; # Print Page Head. print "$doctype\n". $lex{'Edit Attendance'}. " $chartype\n\n"; print "[ ". $lex{Main}. " | \n"; print "". $lex{Attendance}. " ]\n"; print "

". $lex{'Edit Attendance'}. "

\n"; if ($arr{updateflag}) { delete $arr{updateflag}; updateRecord(); } # Print Form Header print "
\n"; print "\n"; print "\n"; print "\n\n"; print "\n\n"; print "\n"; print "\n\n"; print "\n\n"; print "\n\n"; print "
$name
". $lex{'Student Number'}. ""; print "
". $lex{Date}. ""; print "
". $lex{Reason}. "
". $lex{Period}. ""; print "
". $lex{'Subject-Section'}. ""; print "
". $lex{'Late'}. ' ('. $lex{min}. ")"; print "

\n"; #--------------- sub updateRecord { #--------------- # quote all fields foreach $key (keys(%arr)) { $arr{$key} = $dbh->quote($arr{$key}); } $sth = $dbh->prepare("update attend set studentid= $arr{studentid}, absdate= $arr{absdate}, reason= $arr{reason}, period= $arr{period}, subjsec= $arr{subjsec}, late= $arr{late} where attid = $arr{recnum}"); $sth->execute; print '

'; if (not $DBI::errstr ) { print $lex{'Your attendance update is now stored'}. ".

"; } else { print $lex{'There was an error storing your data'}. "
\n"; print $lex{'Please contact your network administrator at'}; print " $adminemail
\n "; print $lex{'Please record the following error string'}. "
\n"; print $DBI::errstr; } print "\n"; #print "

[ ". $lex{Attendance}. " ]

"; print "

\n"; #print "\n"; print "\n"; print "

\n"; print "\n"; exit; }