add history tables to field change upgrade instructions, add hints for pre-5.6 perl...
[freeside.git] / httemplate / misc / queue.cgi
1 <%
2
3 $cgi->param('action') =~ /^(new|del|(retry|remove) selected)$/
4   or die "Illegal action";
5 my $action = $1;
6
7 my $job;
8 if ( $action eq 'new' || $action eq 'del' ) {
9   $cgi->param('jobnum') =~ /^(\d+)$/ or die "Illegal jobnum";
10   my $jobnum = $1;
11   $job = qsearchs('queue', { 'jobnum' => $1 })
12     or die "unknown jobnum $jobnum - ".
13            "it probably completed normally or was removed by another user";
14 }
15
16 if ( $action eq 'new' ) {
17   my %hash = $job->hash;
18   $hash{'status'} = 'new';
19   $hash{'statustext'} = '';
20   my $new = new FS::queue \%hash;
21   my $error = $new->replace($job);
22   die $error if $error;
23 } elsif ( $action eq 'del' ) {
24   my $error = $job->delete;
25   die $error if $error;
26 } elsif ( $action =~ /^(retry|remove) selected$/ ) {
27   foreach my $jobnum (
28     map { /^jobnum(\d+)$/; $1; } grep /^jobnum\d+$/, $cgi->param
29   ) {
30     my $job = qsearchs('queue', { 'jobnum' => $jobnum });
31     if ( $action eq 'retry selected' && $job ) { #new
32       my %hash = $job->hash;
33       $hash{'status'} = 'new';
34       $hash{'statustext'} = '';
35       my $new = new FS::queue \%hash;
36       my $error = $new->replace($job);
37       die $error if $error;
38     } elsif ( $action eq 'remove selected' && $job ) { #del
39       my $error = $job->delete;
40       die $error if $error;
41     }
42   }
43 }
44
45 print $cgi->redirect(popurl(2). "browse/queue.cgi");
46
47 %>