102 lines
2.5 KiB
Perl
102 lines
2.5 KiB
Perl
#!/bin/perl
|
|
|
|
use Mysql;
|
|
use strict;
|
|
use CGI qw(:standard);
|
|
|
|
my $save=param('save');
|
|
|
|
my $so = param('Sonntag');
|
|
my $mo = param('Montag');
|
|
my $di = param('Dienstag');
|
|
my $mi = param('Mittwoch');
|
|
my $don = param('Donnerstag');
|
|
my $fr = param('Freitag');
|
|
my $sa = param('Samstag');
|
|
|
|
print header();
|
|
|
|
print "<html>\n";
|
|
print "<head>\n";
|
|
|
|
print "</head>\n";
|
|
|
|
print "<body>\n";
|
|
|
|
my $dbh = DBI->connect("DBI:mysql:database=c2;host=localhost",'root','', {RaiseError => 1});
|
|
|
|
if ($save eq "") {
|
|
print "<form action='runon.pl'>\n";
|
|
print "An welchen Tagen sollen Checks durchgeführt werden?\n";
|
|
print "<table>\n";
|
|
|
|
my $sth = $dbh->prepare("select description,day,value from run_on order by 'day'");
|
|
$sth->execute;
|
|
while (my $ref = $sth->fetchrow_arrayref()) {
|
|
print "<tr><td>$ref->[0]</td>\n";
|
|
print "<td>";
|
|
if ($ref->[2] == '1') { print "<input checked type='checkbox' name='$ref->[0]'>"; }
|
|
if ($ref->[2] == '0') { print "<input type='checkbox' name='$ref->[0]'>"; }
|
|
print "</td></tr>\n";
|
|
}
|
|
|
|
print "</table>\n";
|
|
print "<input type='hidden' name='save' value='save'>\n";
|
|
print "<input type='submit' value='Speichern'>\n";
|
|
print "</form>\n";
|
|
}
|
|
if ($save eq "save") {
|
|
if ($so) {
|
|
$dbh->do("update run_on set value = 1 where description = 'Sonntag'");
|
|
}
|
|
else {
|
|
$dbh->do("update run_on set value = 0 where description = 'Sonntag'");
|
|
}
|
|
|
|
if ($mo) {
|
|
$dbh->do("update run_on set value = 1 where description = 'Montag'");
|
|
}
|
|
else {
|
|
$dbh->do("update run_on set value = 0 where description = 'Montag'");
|
|
}
|
|
|
|
if ($di) {
|
|
$dbh->do("update run_on set value = 1 where description = 'Dienstag'");
|
|
}
|
|
else {
|
|
$dbh->do("update run_on set value = 0 where description = 'Dienstag'");
|
|
}
|
|
|
|
if ($mi) {
|
|
$dbh->do("update run_on set value = 1 where description = 'Mittwoch'");
|
|
}
|
|
else {
|
|
$dbh->do("update run_on set value = 0 where description = 'Mittwoch'");
|
|
}
|
|
|
|
if ($don) {
|
|
$dbh->do("update run_on set value = 1 where description = 'Donnerstag'");
|
|
}
|
|
else {
|
|
$dbh->do("update run_on set value = 0 where description = 'Donnerstag'");
|
|
}
|
|
|
|
if ($fr) {
|
|
$dbh->do("update run_on set value = 1 where description = 'Freitag'");
|
|
}
|
|
else {
|
|
$dbh->do("update run_on set value = 0 where description = 'Freitag'");
|
|
}
|
|
|
|
if ($sa) {
|
|
$dbh->do("update run_on set value = 1 where description = 'Samstag'");
|
|
}
|
|
else {
|
|
$dbh->do("update run_on set value = 0 where description = 'Samstag'");
|
|
}
|
|
print "<br><br>Gespeichert\n";
|
|
}
|
|
|
|
print "</body>\n";
|
|
print "</html>\n";
|