Files
scripts/Perl CGI C2/admin/edit_check.pl
2024-10-14 00:08:40 +02:00

106 lines
3.5 KiB
Perl

#!/bin/perl
use strict;
use mysql;
use CGI qw(:standard);
my $edit = param('edit');
my $edit1 = param('edit1');
my $descr=param('descr');
my $bedin=param('bedingung');
my $wert=param('wert');
my $dbh = DBI->connect("DBI:mysql:database=c2;host=localhost",'root','', {RaiseError => 1});
print header();
print "<html>\n";
print "<head>\n";
print "<style type='text/css'>\n";
#print "select { font-size:8pt }\n";
print "</style>\n";
print "</head>\n";
print "<body>\n";
print "<b><u>Check editieren</u></b>\n";
if ($edit eq "") {
my $sth = $dbh->prepare("select ind,description,beding,wert from checks order by 'description'");
$sth->execute;
print "<form action='edit_check.pl'>\n";
print "<table>\n";
while (my $ref = $sth->fetchrow_arrayref()) {
print "<tr>\n";
print "<td><input type='radio' name='edit' value='$ref->[0]'></td>\n";
print "<td><input type='text' readonly value='$ref->[1]'></td>\n";
print "<td><input type='text' readonly value='$ref->[2]'></td>\n";
print "<td><input type='text' readonly value='$ref->[3]'></td>\n";
print "</tr>\n";
}
print "<tr><td></td>\n<td><input type='submit' name='edit1' value='Edit'></td></tr>\n";
print "</table>\n";
print "</form>\n";
}
else {
if ($edit1 eq "Edit") {
my $sth = $dbh->prepare("select ind,description,beding,wert from checks where ind='$edit'");
$sth->execute;
while (my $ref = $sth->fetchrow_arrayref()) {
print "<form action='edit_check.pl'>\n";
print "<table border='1'>\n";
print "<tr>\n<td>Description</td>\n";
print "<td><input name='descr' type='text' value='$ref->[1]'></td>\n";
print "</tr>\n";
print "<tr>\n";
print "<td>Prüfung</td>\n";
print "<td>";
print "<select name='bedingung' value='$ref->[2]'>\n";
my $seltxt="";
if ($ref->[2] eq "EQ") { $seltxt=" selected"; }
print "<option $seltxt>EQ</option>\n";
$seltxt="";
if ($ref->[2] eq "NEQ") { $seltxt=" selected"; }
print "<option $seltxt>NEQ</option>\n";
$seltxt="";
if ($ref->[2] eq "LT") { $seltxt=" selected"; }
print "<option $seltxt>LT</option>\n";
$seltxt="";
if ($ref->[2] eq "NLT") { $seltxt=" selected"; }
print "<option $seltxt>NLT</option>\n";
$seltxt="";
if ($ref->[2] eq "GT") { $seltxt=" selected"; }
print "<option $seltxt>GT</option>\n";
$seltxt="";
if ($ref->[2] eq "NGT") { $seltxt=" selected"; }
print "<option $seltxt>NGT</option>\n";
$seltxt="";
if ($ref->[2] eq "BT") { $seltxt=" selected"; }
print "<option $seltxt>BT</option>\n";
$seltxt="";
if ($ref->[2] eq "NBT") { $seltxt=" selected"; }
print "<option $seltxt>NBT</option>\n";
$seltxt="";
if ($ref->[2] eq "RE") { $seltxt=" selected"; }
print "<option $seltxt>RE</option>\n";
print "</select>\n";
print "</tr>\n";
print "<tr>\n";
print "<td>Vergleichswert</td>\n";
print "<td><input name='wert' type='text' value='$ref->[3]'></td>\n";
print "</tr>\n";
print "</table>\n";
print "<input type='submit' name='edit1' value='Speichern'>\n";
print "<input type='hidden' name='edit' value='$edit'>\n";
print "</form>\n";
}
}
if ($edit1 eq "Speichern") {
$dbh->do("update checks set description='$descr', beding='$bedin', wert='$wert' where ind='$edit'");
#print "update checks set description='$descr', beding='$bedin', wert='$wert' where ind='$edit'";
print "<br>Gespeichert\n";
}
#print "Löschen durchgeführt!";
}
print "</body>\n";
print "</html>\n";