Will things ever be the same again?
[freeside.git] / httemplate / search / queue.html
1 %
2 %
3 %my $hashref = {};
4 %
5 %my $conf = new FS::Conf;
6 %my $dangerous = $conf->exists('queue_dangerous_controls');
7 %
8 %my $noactions = 0;
9 %
10 %my $count_query = 'SELECT COUNT(*) FROM queue'; # + $hashref
11 %
12 %my $areboxes = 0;
13 %
14 %
15 <% include( 'elements/search.html',
16                  'title'       => 'Job Queue',
17                  'menubar'     => [ 'Main menu' => $p, ],
18                  'name'        => 'jobs',
19                  'query'       => { 'table'     => 'queue',
20                                     'hashref'   => $hashref,
21                                     'extra_sql' => 'ORDER BY jobnum',
22                                   },
23                  'count_query' => $count_query,
24                  'header' => [ '#',
25                                'Job',
26                                'Args',
27                                'Date',
28                                'Status',
29                                'Account', # unless $hashref->{'svcnum'}
30                                '', # checkbox column
31                              ],
32                  'fields' => [
33                                'jobnum',
34                                'job',
35                                sub {
36                                  my $queue = shift;
37                                  if (    $dangerous
38                                       || $queue->job !~ /^FS::part_export::/
39                                       || !$noactions
40                                     )
41                                  {
42                                    encode_entities( join(' ', $queue->args) );
43                                  } else {
44                                    '';
45                                  }
46                                },
47                                sub {
48                                  time2str( "%a %b %e %T %Y", shift->_date );
49                                },
50                                sub {
51                                  my $queue = shift;
52                                  my $jobnum = $queue->jobnum;
53                                  my $status = $queue->status;
54                                  $status .= ': '. $queue->statustext
55                                    if $queue->statustext;
56                                  my @queue_depend = $queue->queue_depend;
57                                  $status .= ' (waiting for '.
58                                             join(', ', map { $_->depend_jobnum }
59                                                            @queue_depend
60                                                 ). 
61                                             ')'
62                                    if @queue_depend;
63                                  my $changable = $dangerous
64                                                  || ( ! $noactions
65                                                       && $status =~ /^failed/
66                                                       || $status =~ /^locked/
67                                                     );
68                                  if ( $changable ) {
69                                    $status .=
70                                      qq! (&nbsp;<A HREF="$p/misc/queue.cgi?jobnum=$jobnum&action=new">retry</A>&nbsp;|!.
71                                      qq!&nbsp;<A HREF="$p/misc/queue.cgi?jobnum=$jobnum&action=del">remove</A>&nbsp;)!;
72                                  }
73                                  $status;
74                                },
75                                sub {
76                                  my $queue = shift;
77                                  # return '' if $hashref->{'svcnum'}
78                                  my $cust_svc = $queue->cust_svc;
79                                  my $account;
80                                  if ( $cust_svc ) {
81                                    my $table = $cust_svc->part_svc->svcdb;
82                                    my $label = ( $cust_svc->label )[1];
83                                    qq!<A HREF="../view/$table.cgi?!. $queue->svcnum.
84                                    qq!">$label</A>!;
85                                  } else {
86                                    '';
87                                  }
88                                },
89                                sub {
90                                  my $queue = shift;
91                                  my $jobnum = $queue->jobnum;
92                                  my $status = $queue->status;
93                                  my $changable = $dangerous
94                                                  || ( ! $noactions
95                                                       && $status eq 'failed'
96                                                       || $status eq 'locked'
97                                                     );
98                                  if ( $changable ) {
99                                    $areboxes = 1;
100                                    qq!<INPUT NAME="jobnum$jobnum" TYPE="checkbox" VALUE="1">!;
101                                  } else {
102                                    '';
103                                  }
104                                },
105                              ],
106                  #'links' =>  [
107                  #              '',
108                  #              '',
109                  #              '',
110                  #              '',
111                  #              '',
112                  #              '', #$acct_link,
113                  #              '',
114                  #            ],
115                  'html_foot' => sub {
116                                   if ( $areboxes ) {
117                                     '<BR><INPUT TYPE="submit" NAME="action" VALUE="retry selected">'.
118                                     '<INPUT TYPE="submit" NAME="action" VALUE="remove selected"><BR>';
119                                   } else {
120                                     '';
121                                   }
122                                 },
123              )
124
125 %>