#!/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.
use DBI;
use CGI;
my %lex = ('Student Medical Report' => 'Student Medical Report',
'Main' => 'Main',
'Name' => 'Name',
'Med' => 'Med',
'Medical' => 'Medical',
'Address' => 'Address',
'Parent 1' => 'Parent 1',
'Parent 2' => 'Parent 2',
'Hr' => 'Hr',
'Gr' => 'Gr',
'Bdate' => 'Bdate',
'Health' => 'Health',
'Print/View Medical Report' => 'Print/View Medical Report',
'View Log File' => 'View Log File',
'Room' => 'Room',
);
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 $type = $arr{type}; # Type of Report: 'Web' or 'Pdf'
my $search = $arr{search}; # Word(s) to search for in medical field.
my @search = split /\s/,$search;
my $select;
if ($search){
$select = " where ";
foreach my $key (@search){ # add each word into search
$select .= " medical $sql{like} '%$key%' or ";
}
$select =~ s/or $//; # remove trailing 'or'
}
my $dsn = "DBI:$dbtype:dbname=$dbase";
my $dbh = DBI->connect($dsn,$user,$password);
my $sortorder = "homeroom, lastname, firstname";
my $sth = $dbh->prepare("select * from student
$select order by $sortorder");
$sth->execute;
if ($DBI::errstr){ print $DBI::errstr; die "$DBI::errstr: $! \n";}
print "$doctype\n