my @queue = qsearch( 'queue', $hashref );
return '' unless scalar(@queue);
- my $html = FS::CGI::table(). <<END;
+ my $p = FS::CGI::popurl(2);
+
+ my $html = qq!<FORM ACTION="$p/misc/queue.cgi" METHOD="POST">!.
+ FS::CGI::table(). <<END;
<TR>
<TH COLSPAN=2>Job</TH>
<TH>Args</TH>
my $dangerous = $conf->exists('queue_dangerous_controls');
- my $p = FS::CGI::popurl(2);
+ my $areboxes = 0;
+
foreach my $queue ( sort {
$a->getfield('jobnum') <=> $b->getfield('jobnum')
} @queue ) {
my $date = time2str( "%a %b %e %T %Y", $queue->_date );
my $status = $queue->status;
$status .= ': '. $queue->statustext if $queue->statustext;
- if ( $dangerous
- || ( ! $noactions && $status =~ /^failed/ || $status =~ /^locked/ ) ) {
+ my $changable = $dangerous
+ || ( ! $noactions && $status =~ /^failed/ || $status =~ /^locked/ );
+ if ( $changable ) {
$status .=
qq! ( <A HREF="$p/misc/queue.cgi?jobnum=$jobnum&action=new">retry</A> |!.
qq! <A HREF="$p/misc/queue.cgi?jobnum=$jobnum&action=del">remove</A> )!;
$html .= "<TD>$account</TD>";
}
+ if ( $changable ) {
+ $areboxes=1;
+ $html .=
+ qq!<TD><INPUT NAME="jobnum$jobnum" TYPE="checkbox" VALUE="1"></TD>!;
+
+ }
+
$html .= '</TR>';
}
$html .= '</TABLE>';
+ if ( $areboxes ) {
+ $html .= '<BR><INPUT TYPE="submit" NAME="action" VALUE="retry selected">'.
+ '<INPUT TYPE="submit" NAME="action" VALUE="remove selected"><BR>';
+ }
+
$html;
}
=head1 VERSION
-$Id: queue.pm,v 1.10 2002-03-27 07:08:08 ivan Exp $
+$Id: queue.pm,v 1.11 2002-04-13 08:51:54 ivan Exp $
=head1 BUGS
<%
-$cgi->param('jobnum') =~ /^(\d+)$/ or die "Illegal jobnum";
-my $jobnum = $1;
-my $job = qsearchs('queue', { 'jobnum' => $1 })
- or die "unknown jobnum $jobnum";
-
-$cgi->param('action') =~ /^(new|del)$/ or die "Illegal action";
+$cgi->param('action') =~ /^(new|del|(retry|remove) selected)$/
+ or die "Illegal action";
my $action = $1;
+my $job;
+if ( $action eq 'new' || $action eq 'del' ) {
+ $cgi->param('jobnum') =~ /^(\d+)$/ or die "Illegal jobnum";
+ my $jobnum = $1;
+ $job = qsearchs('queue', { 'jobnum' => $1 })
+ or die "unknown jobnum $jobnum";
+}
+
if ( $action eq 'new' ) {
my %hash = $job->hash;
$hash{'status'} = 'new';
} elsif ( $action eq 'del' ) {
my $error = $job->delete;
die $error if $error;
+} elsif ( $action =~ /^(retry|remove) selected$/ ) {
+ foreach my $jobnum (
+ map { /^jobnum(\d+)$/; $1; } grep /^jobnum\d+$/, $cgi->param
+ ) {
+ my $job = qsearchs('queue', { 'jobnum' => $jobnum });
+ if ( $action eq 'retry selected' && $job ) { #new
+ my %hash = $job->hash;
+ $hash{'status'} = 'new';
+ $hash{'statustext'} = '';
+ my $new = new FS::queue \%hash;
+ my $error = $new->replace($job);
+ die $error if $error;
+ } elsif ( $action eq 'remove selected' && $job ) { #del
+ my $error = $job->delete;
+ die $error if $error;
+ }
+ }
}
print $cgi->redirect(popurl(2). "browse/queue.cgi");