#!/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 = ('Subject Enrollment Summary' => 'Subject Enrollment Summary', 'Main' => 'Main', 'Report Card' => 'Report Card', 'Subjects Enrolled' => 'Subjects Enrolled', 'Students' => 'Students', 'Subjects NOT Enrolled' => 'Subjects NOT Enrolled', ); use DBI; use CGI; require "../../etc/admin.conf" or die "Cannot open admin.conf!"; my $q = new CGI; print $q->header; my %arr = $q->Vars; my $dsn = "DBI:$dbtype:dbname=$dbase"; my $dbh = DBI->connect($dsn,$user,$password); # Create Sorted List of Subject-Section Code in Subject table my $sth = $dbh->prepare("select distinct subjsec, grade, description from subject order by grade, description,subjsec"); $sth->execute; if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr; } while ( my ($subjsec, $gr, $desc) = $sth->fetchrow ) { push @subjarray,$subjsec; } # Now run through eval table finding folks my @eval; $sth = $dbh->prepare("select distinct subjcode from eval order by subjcode desc"); $sth->execute; if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr; } my $sth1 = $dbh->prepare("select description, grade from subject where subjsec = ?"); while ( my $subjsec = $sth->fetchrow ) { $sth1->execute( $subjsec ); my ($description, $grade) = $sth1->fetchrow; $eval{$subjsec} = "1"; push @eval,"$grade:$description:$subjsec"; } @eval = sort @eval; # Print HTML Page Header print "$doctype\n". $lex{'Subject Enrollment Summary'}. " $chartype\n\n"; print "[ ". $lex{Main}. " |\n"; print "". $lex{'Report Card'}. " ]\n"; print "

". $lex{'Subject Enrollment Summary'}. "

\n"; print "
\n"; print "\n"; foreach my $subject ( @eval ){ # those already enrolled my ($grade,$description,$subjsec) = split /:/,$subject; # print the subject print "\n"; $sth=$dbh->prepare("select distinct subjcode,studnum from eval where subjcode = '$subjsec'"); $sth->execute; if ($DBI::errstr){ print $DBI::errstr; die; } $rows = $sth->rows; print "\n"; } print "
". $lex{'Subjects Enrolled'}. "". $lex{Students}. "
$grade) $description ($subjsec)$rows
\n"; print "\n"; print "\n"; foreach my $subjsec ( @subjarray ) { if ( not $eval{$subjsec} ) { $sth1 = $dbh->prepare("select description,grade from subject where subjsec = ?"); $sth1->execute( $subjsec ); if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr; } my ($description,$grade) = $sth1->fetchrow; print "\n"; } } print "
". $lex{'Subjects NOT Enrolled'}. "
$grade) $description ($subjsec)
\n"; print"
\n";