# Lib Schedule
%lex = ('Term' => 'Term',
'Not Found' => 'Not Found',
'not defined' => 'not defined',
'Grade' => 'Grade',
);
# Functions:
# findCurrentSubjects(teacher,date,dbh);
# Returns hash of subjsec and periods in the day.
# findDayInCycle - IN: date OUT: an integer for DayInCycle
# fillDate - IN: isodate(2005-1-1) OUT: full isodate (2005-01-01)
# findFutureClass - find a future class (subjsec)
# IN - date, subjsec, classtimes,
# RETURN - period, date.
# prTeacherTimetable - IN: term,subjectref(ref to subjsec array)
# mkTimetable - mk 2D strucutre for teacher and term.
#----------------------
sub findCurrentSubjects {
#----------------------
use Time::JulianDay;
my ($userid, $date, $dbh ) = @_; # passed teacher, date to check, dic, db handle;
my $currjd = julian_day( split(/-/, $date));
# Read in values from conf_system;
my $sth = $dbh->prepare("select datavalue from conf_system
where dataname = ?");
foreach my $dataname ( qw( g_MTrackTermType g_MTrackTerm
r_AdditionalComments g_AttendanceEntryMethod )) {
$sth->execute( $dataname );
if ( $DBI::errstr ) { print $DBI::errstr; die $DBI::errstr; }
my $datavalue = $sth->fetchrow;
eval $datavalue;
if ( $@ ) {
print "$lex{Error} $@
\n";
die "$lex{Error} $@\n";
}
}
# now find if any scheduled periods on this date
my $dayincycle = findDayInCycle( $date, $dbh );
# print "Day:$day
\n";
# Get subjects taught by this teacher
my $sth= $dbh->prepare("select subjcode, subjsec, smdesc, description,
grade, startrptperiod, endrptperiod from subject
where subject.teacher = ?");
$sth->execute( $userid );
if ( $DBI::errstr ){ print $DBI::errstr; die $DBI::errstr; }
my $sth1 = $dbh->prepare("select count(*) from eval where subjcode = ?");
my %subjects;
while ( my ( $subjcode, $subjsec, $smdesc, $description, $grade, $sterm, $eterm )
= $sth->fetchrow ) {
# skip AdditionalComments - not subjects used for attendance
if ( $r_AdditionalComments{$subjcode} or
$r_AdditionalComments{$subjsec} ) { next; } #skip
# Check for student enrollments
$sth1->execute( $subjsec );
if ( $DBI::errstr ){ print $DBI::errstr; die $DBI::errstr; }
my $count = $sth1->fetchrow;
if ( $count < 1) { next; } # skip if no enrolled students.
# find term, to see if current.
if ( not $grade ) {
print "