#!/usr/bin/perl # Copyright 2001-2009 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 = ('Main' => 'Main', 'Fees' => 'Fees', 'Lock Number' => 'Lock Number', 'Combination' => 'Combination', 'Comment' => 'Comment', 'Edit Lock' => 'Edit Lock', 'Update Entry' => 'Update Entry', 'Lock Record Edited' => 'Lock Record Edited', 'Error' => 'Error', 'Pool' => 'Pool', ); my $self = 'lockedit.pl'; use CGI; use DBI; use Cwd; eval require "../../etc/admin.conf"; if ( $@ ) { print $lex{Error}. ": $@
\n"; die $lex{Error}. ": $@\n"; } my $q = new CGI; print $q->header( -charset, $charset ); my %arr = $q->Vars; my $dsn = "DBI:$dbtype:dbname=$dbase"; my $dbh = DBI->connect($dsn,$user,$password); $dbh->{mysql_enable_utf8} = 1; # Get current dir so know what CSS to display; if (getcwd() =~ /tcgi/){ # we are in tcgi $css = $tchcss; $homepage = $tchpage; } # Show page Header print "$doctype\n". $lex{'Edit Lock'}. "\n"; print "\n"; print "$chartype\n[ ". $lex{Main}. " |\n"; print " ". $lex{Fees}. " ]\n"; print "

". $lex{'Edit Lock'}. "

\n"; if ( $arr{writeflag} ){ # Write values and exit; delete $arr{writeflag}; updateRecord(); } $sth = $dbh->prepare("select * from lok_lock where id = ? "); $sth->execute( $arr{id} ); if ( $DBI::errstr ) {print $DBI::errstr; die $DBI::errstr;} my ( $id,$lock_num, $combination, $pool, $comment ) = $sth->fetchrow; # Setup the form and start of table. print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; # Print Submit Row print "\n"; print "
". $lex{'Lock Number'}. "\n"; print "\n"; print "
". $lex{Combination}; print "\n"; print "\n"; print "
". $lex{Pool}; print "\n"; print "\n"; print "
". $lex{Comment}; print "\n"; print "\n"; print "
"; print "
\n
\n"; #--------------- sub updateRecord { #--------------- my $id = $arr{id}; delete $arr{id}; #foreach my $key ( sort keys %arr ) { print "K:$key V:$arr{$key}
\n"; } foreach my $key ( sort keys %arr ) { my $sth = $dbh->prepare("update lok_lock set $key = ? where id = ?"); $sth->execute( $arr{$key}, $id ); if ( $DBI::errstr ){ print $DBI::errstr; die $DBI::errstr; } } print "". $lex{'Lock Record Edited'}. "\n"; print "

[ ". $lex{Fees}. " ]

\n"; print "\n"; exit; } # End of updateRecord