From f70985da9714a8a2c5dd87f56d891ed0197ef590 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 13 Apr 2002 08:51:54 +0000 Subject: bulk queue operations (closes: Bug#389) --- FS/FS/queue.pm | 27 ++++++++++++++++++++++----- httemplate/misc/queue.cgi | 33 +++++++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/FS/FS/queue.pm b/FS/FS/queue.pm index 4b880a23c..5719eff70 100644 --- a/FS/FS/queue.pm +++ b/FS/FS/queue.pm @@ -241,7 +241,10 @@ sub joblisting { my @queue = qsearch( 'queue', $hashref ); return '' unless scalar(@queue); - my $html = FS::CGI::table(). <!. + FS::CGI::table(). < Job Args @@ -253,7 +256,8 @@ END 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 ) { @@ -270,8 +274,9 @@ END 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! ( retry |!. qq! remove )!; @@ -300,12 +305,24 @@ END $html .= "$account"; } + if ( $changable ) { + $areboxes=1; + $html .= + qq!!; + + } + $html .= ''; } $html .= ''; + if ( $areboxes ) { + $html .= '
'. + '
'; + } + $html; } @@ -314,7 +331,7 @@ END =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 diff --git a/httemplate/misc/queue.cgi b/httemplate/misc/queue.cgi index 7e962d498..8c1e5362d 100644 --- a/httemplate/misc/queue.cgi +++ b/httemplate/misc/queue.cgi @@ -1,13 +1,17 @@ <% -$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'; @@ -18,6 +22,23 @@ if ( $action eq '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"); -- cgit v1.2.1