#!/usr/bin/perl # Copyright 2001-2006 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 $self = 'rptphone.pl'; my %lex = ('Student Phone List' => 'Student Phone List', 'Main' => 'Main', 'Attendance' => 'Attendance', 'Name' => 'Name', 'HRoom' => 'HRoom', 'Grade' => 'Grade', 'Parent 1' => 'Parent 1', 'Parent 2' => 'Parent 2', 'Emergency' => 'Emergency', 'Homeroom' => 'Homeroom', 'Sort by' => 'Sort by', 'Lastname' => 'Lastname', ); 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 = "lastname, firstname"; my $mode = 'lastname'; if ($arr{sortorder} eq $lex{Homeroom}) { $sortorder = "homeroom, lastname, firstname"; $mode = 'homeroom'; } elsif ($arr{sortorder} eq $lex{Grade}) { $sortorder = "grade, lastname, firstname"; $mode = 'grade'; } my $select; if ($arr{group}) { if ($mode eq 'grade') { $select = "where grade = '$arr{group}'"; } elsif ($mode eq 'homeroom') { $select = "where homeroom = '$arr{group}'"; } } my $sth = $dbh->prepare("select * from student $select order by $sortorder"); $sth->execute; if ($DBI::errstr) { print $DBI::errstr; die $DBI::errstr; } print "$doctype\n". $lex{'Student Phone List'}. " $chartype\n[ ". $lex{Main}. " ]\n"; # Selection Form. print "
\n"; print "\n"; print " ". $lex{Homeroom}. '/'. $lex{Grade}; print " "; print "
\n"; print "

". $lex{'Student Phone List'}. "

$currdate

\n"; my $curroom = -1; my $currgrade = -1; my $first = 1; #print "Mode: $mode
\n"; while (my @arr = $sth->fetchrow) { $oldroom = $curroom; $curroom = $arr[6]; $oldgrade = $currgrade; $currgrade = $arr[5]; if ( ($curroom ne $oldroom and $mode eq 'homeroom') or ($currgrade ne $oldgrade and $mode eq 'grade') or ($first and $mode eq 'lastname') ){ if (not $first) { print "\n"; } else { $first = 0; } print "

"; if ($mode eq 'grade') { print $lex{Grade}. " $currgrade

\n"; } elsif ($mode eq 'homeroom') { print $lex{Homeroom}. " $curroom

\n"; } print ""; print '\n"; } print "\n"; print "\n"; print "\n"; print "\n"; } print "
'. $lex{Name}. ' / '. $lex{HRoom}. ' - '. $lex{Grade}; print ''. $lex{'Parent 1'}. ''. $lex{'Parent 2'}; print ''. $lex{Emergency}. "
$arr[1], $arr[2] $arr[3] ($arr[4])
\n"; print "Hr:$arr[6]
Gr:$arr[5]
Rel: $arr[27]
$arr[29]
H: $arr[30]
W: $arr[31]
C:$arr[32]
Rel: $arr[38]
$arr[40]
H: $arr[41]
W: $arr[42]
C:$arr[43]
Rel: $arr[49]
$arr[50]
H: $arr[51]
W: $arr[52]
C:$arr[53]
\n";