<%init>
my $n = 0;
my $onload = '';
while ($n < $num_actions) {
$onload .= "regenerate(document.ruleform.action$n, document.ruleform.device$n); ";
$n++;
}
%init>
<%def _contact_options>
<%args>
$pua_id
$selected => -1
%args>
<%init>
my $dbh = DBI->connect('dbi:Pg:dbname=pua', 'pua', 'pua') or die "Couldn't connect to database: " . DBI->errstr;
my $sth = $dbh->prepare("SELECT contact_id, contact_name, comment from pua_contact WHERE pua_id=$pua_id ORDER BY contact_name;");
$sth->execute or die "Execute failed: " . $sth->errstr;
while (my @record = $sth->fetchrow_array) {
my $sel = '';
if ($record[0] == $selected) {
$sel = "selected=\"selected\"";
}
print "\n";
}
%init>
%def>
<%def _action_options>
<%args>
$pua_id
$selected => ''
%args>
<%init>
my $dbh = DBI->connect('dbi:Pg:dbname=pua', 'pua', 'pua') or die "Couldn't connect to database: " . DBI->errstr;
my $sth = $dbh->prepare("SELECT rule_id, rule_name from rule WHERE pua_id=$pua_id ORDER BY rule_name;");
$sth->execute or die "Execute failed: " . $sth->errstr;
while (my @record = $sth->fetchrow_array) {
my $sel = '';
if ($record[1] eq $selected) {
$sel = "selected=\"selected\"";
}
print "\n";
}
%init>
%def>
<%def _device_options>
<%args>
$pua_id
$selected => -1
$select_name
%args>
<%init>
my $dbh = DBI->connect('dbi:Pg:dbname=pua', 'pua', 'pua') or die "Couldn't connect to database: " . DBI->errstr;
my $sth = $dbh->prepare("SELECT device_id, device_name from owner_device WHERE pua_id=$pua_id ORDER BY device_name;");
$sth->execute or die "Execute failed: " . $sth->errstr;
my $rv = '';
while (my @record = $sth->fetchrow_array) {
my $sel = '';
if ($record[0] == $selected) {
$sel = "selected=\"selected\"";
}
$rv .= "\n";
}
if ($rv ne '') {
print "";
} else {
print ": No device to connect to. Please enter one here";
}
%init>
%def>