#!/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 = ('Youngest in Family' => 'Youngest in Family', 'Main' => 'Main', 'Name' => 'Name', 'Parent 1' => 'Parent 1', 'Parent 2' => 'Parent 2', 'Lastname, Firstname' => 'Lastname, Firstname', 'Homeroom, Lastname, Firstname' => 'Homeroom, Lastname, Firstname', 'Grade, Lastname, Firstname' => 'Grade, Lastname, Firstname', 'Sort by' => 'Sort by', 'Select' => 'Select', 'Grade' => 'Grade', 'Homeroom' => 'Homeroom' ); my $self = 'rptyoungest.pl'; use DBI; use CGI; 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; # Read config variables require "../etc/admin.conf" || die "Cannot read admin.conf!"; my $dsn = "DBI:$dbtype:dbname=$dbase"; my $dbh = DBI->connect($dsn,$user,$password); my $sortorder = "homeroom, lastname, firstname"; if ( $arr{sortorder} ) { $sortorder = $arr{sortorder}; delete $arr{sortorder}; } my $select; if ( $arr{group} or $arr{homeroom} ) { if ( $arr{select} eq $lex{Grade} ) { # Find this grade; my $grp = $dbh->quote( $arr{group} ); $select = "and grade = $grp"; } elsif ( $arr{select} eq $lex{Homeroom} ) { my $grp = $dbh->quote( $arr{group} ); $select = "and homeroom = $grp"; } else { # must be old homeroom... my $homeroom = $dbh->quote($arr{homeroom}); $select = "and homeroom = $homeroom"; } } # Select Data my $sth = $dbh->prepare("select lastname, firstname, initial, homeroom, grade, youngest, relation1, name1, hphone1, wphone1, relation2, name2, hphone2, wphone2 from student where youngest = 'y' $select order by $sortorder"); $sth->execute; if ($DBI::errstr) { print $DBI::errstr; die $DBI::errstr; } # Print Page Header print "$doctype\n". $lex{'Youngest in Family'}. " $chartype\n\n"; print "
"; print "[ ". $lex{Main}. " ]\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print '

'. $lex{'Youngest in Family'}. "

$schoolname - $currdate

\n"; my $curroom = -1; my $first = 1; while (my ($lastname, $firstname, $middlename, $homeroom, $grade, $youngest, $relation1, $parent1, $hphone1, $wphone1, $relation2, $parent2, $hphone2, $wphone2) = $sth->fetchrow) { $oldroom = $curroom; $curroom = $hroom; if ($curroom ne $oldroom) { if (not $first) { print "

\n"; } else { $first = 0; } print "\n"; print '\n"; } print "\n"; print "\n"; print "\n"; } print "
'. $lex{Name}. ''. $lex{'Parent 1'}. ''. $lex{'Parent 2'}. "
$lastname, $firstname $middlename
Gr: $grade
Hr: $homeroom
Rel: $relation1
$parent1
H:$hphone1
W:$wphone1
Rel: $relation2
$parent2
H:$hphone2
W:$wphone2
\n";