#!/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 = ('Date Entry' => 'Date Entry', 'EOY' => 'EOY', 'Type' => 'Type', 'StatHol' => 'StatHol', 'Inservice' => 'Inservice', 'Holiday' => 'Holiday', 'Other' => 'Other', 'Description' => 'Description', 'Day in Cycle?' => 'Day in Cycle?', 'No' => 'No', 'Yes' => 'Yes', 'Save Date' => 'Save Date', 'Date' => 'Date', 'yymmdd' => 'yymmdd', 'Add Another Date' => 'Add Another Date', 'There was an error storing your data' => 'There was an error storing your data', 'Please record the following error string' => 'Please record the following error string', 'Contact' => 'Contact', 'The date is now stored' => 'The date is now stored', ); my $self = 'dateadd0.pl'; use DBI; use CGI; my $q = new CGI; print $q->header; my %arr = $q->Vars; # Read Config variables require "../../etc/admin.conf"; my $dsn = "DBI:$dbtype:dbname=$dbase"; my $dbh = DBI->connect($dsn,$user,$password); print "$doctype\n". $lex{'Date Entry'}. " \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "$chartype\n[ ". $lex{EOY}. " ]

". $lex{'Date Entry'}. "


\n"; # Write the records. if ( $arr{writeflag} ) { delete $arr{writeflag}; writeDates(); } print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
". $lex{Date}. " (". $lex{yymmdd}. ")
". $lex{Type}. "
". $lex{Description}. " 1
". $lex{Description}. " 2
". $lex{'Day in Cycle?'}. "
\n"; print "
\n"; print "\n"; print "\n"; #------------- sub writeDates { #------------- # Check for Yes/No values in dayincycle. if ($arr{dayincycle} eq $lex{No} ) { $arr{dayincycle} = 'N'; } # We can leave the yes values...(?). Cursory testing is yes. foreach my $key ( keys %arr ) { #print "K:$key V: $arr{$key}
\n"; $arr{$key} = $dbh->quote( $arr{$key} ); } $sth = $dbh->prepare("insert into dates values ( $sql{default}, $arr{date}, $arr{type}, $arr{field1}, $arr{field2}, $arr{dayincycle} )"); if ($DBI::errstr ) { print $DBI::errstr; die $DBI::errstr; } $sth->execute; if (not $DBI::errstr ) { print "

". $lex{'The date is now stored'}. ".

"; } else { print "

". $lex{'There was an error storing your data'}; print $lex{Contact}. " $adminname $adminemail\n"; print $lex{'Please record the following error string'}. ": $DBI::errstr \n"; } print "

[ ". $lex{EOY}. " |\n"; print " ". $lex{'Add Another Date'}. " ]\n"; print "

"; exit; }