#!/usr/bin/perl
# Copyright 2001-2008 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.
%lex = ( 'Edit' => 'Edit',
'Student Table' => 'Student Table',
'Main' => 'Main',
'Your student update is now stored' => 'Your student update is now stored',
'Bold' => 'Bold',
'Required Field' => 'Required Field',
'Cannot open' => 'Cannot open',
'Edit Another Student' => 'Edit Another Student',
'Main' => 'Main',
'There was an error storing your data' => 'There was an error storing your data',
'Contact' => 'Contact',
'Update Student Data' => 'Update Student Data',
'Withdrawn' => 'Withdrawn',
'Preregistration' => 'Preregistration',
'Record the following error' => 'Record the following error',
);
use CGI;
use DBI;
my $self = 'studed.pl';
my $q = new CGI;
print $q->header;
my %arr = $q->Vars;
eval require "../etc/admin.conf";
if ( $@ ) {
print $lex{Error}. " $@
\n";
die $lex{Error}. " $@\n";
}
eval require "../lib/libmeta.pl";
if ( $@ ) {
print $lex{Error}. " $@
\n";
die $lex{Error}. " $@\n";
}
# Don't make into 'my' vars...
$dsn = "DBI:$dbtype:dbname=$dbase";
$dbh = DBI->connect($dsn,$user,$password);
if ( not $arr{tb} ) { # no passed table to edit...
$arr{tb} = 'student';
}
if ( $arr{writeflag} ) {
delete $arr{writeflag};
updateRecord();
}
# Select table to Edit.
my $table; # table to edit...
if ( $arr{tb} eq 'wd' ){ # if passed a tb=wd param, then edit alt table.
$sth = $dbh->prepare("select * from studentwd where studid = ?");
$wd = ''. $lex{Withdrawn}. '';
$table = 'studentwd';
} elsif ( $arr{tb} eq 'prereg' ){ # if tb=pre then edit prereg table.
$sth = $dbh->prepare("select * from prereg where studid = ?");
$wd = ''. $lex{Preregistration}. '';
$table = 'prereg';
} else {
$sth = $dbh->prepare("select * from student where studid = ?");
$table = 'student';
}
$sth->execute( $arr{recnum} );
if ($DBI::errstr){ print $DBI::errstr; die $DBI::errstr;}
@rec = $sth->fetchrow;
$studnum = $rec[4];
print "$doctype\n
[ ". $lex{'Edit Another Student'}; print " | ". $lex{Main}; print " ]