Revert "RT# 39340 - configured the minimal selfservice to get mac address from radius...
[freeside.git] / httemplate / search / queue.html
1 <& elements/search.html,
2                  'title'       => 'Job Queue',
3                  'name'        => 'jobs',
4                  'html_form'   => qq!<FORM NAME="jobForm" ACTION="$p/misc/queue.cgi" METHOD="POST">!,
5                  'query'       => { 'table'     => 'queue',
6                                     'hashref'   => $hashref,
7                                     'order_by' => 'ORDER BY jobnum',
8                                   },
9                  'count_query' => $count_query,
10                  'header' => [ '#',
11                                'Job',
12                                'Args',
13                                'Date',
14                                'Status',
15                                'Account', # unless $hashref->{'svcnum'}
16                                'Employee',
17                                '', # checkbox column
18                              ],
19                  'fields' => [
20                                'jobnum',
21                                'job',
22                                sub {
23                                  my $queue = shift;
24                                  if (    $dangerous
25                                       || $queue->job !~ /^FS::part_export::/
26                                       || !$noactions
27                                     )
28                                  {
29                                    encode_entities( join(' ', $queue->args) );
30                                  } else {
31                                    '';
32                                  }
33                                },
34                                sub {
35                                  time2str( "%a %b %e %T %Y", shift->_date );
36                                },
37                                sub {
38                                  my $queue = shift;
39                                  my $jobnum = $queue->jobnum;
40                                  my $status = $queue->status;
41                                  $status .= ': '. $queue->statustext
42                                    if $queue->statustext;
43                                  my @queue_depend = $queue->queue_depend;
44                                  $status .= ' (waiting for '.
45                                             join(', ', map { $_->depend_jobnum }
46                                                            @queue_depend
47                                                 ). 
48                                             ')'
49                                    if @queue_depend;
50                                  my $changable = $dangerous
51                                                  || ( ! $noactions
52                                                       && $status =~ /^failed/
53                                                       || $status =~ /^locked/
54                                                       || $status =~ /^done/
55                                                     );
56                                  if ( $changable ) {
57                                    $status .= qq! (!;
58                                    $status .=
59                                      qq! &nbsp;<A HREF="$p/misc/queue.cgi?jobnum=$jobnum&action=new">retry</A>&nbsp;|!
60                                      unless $status =~ /^done/;
61                                    $status .=
62                                      qq!&nbsp;<A HREF="$p/misc/queue.cgi?jobnum=$jobnum&action=del">remove</A>&nbsp;)!;
63                                  }
64                                  $status;
65                                },
66                                sub {
67                                  my $queue = shift;
68                                  # return '' if $hashref->{'svcnum'}
69                                  my $cust_svc = $queue->cust_svc;
70                                  my $account;
71                                  if ( $cust_svc ) {
72                                    my $table = $cust_svc->part_svc->svcdb;
73                                    my $label = ( $cust_svc->label )[1];
74                                    qq!<A HREF="../view/$table.cgi?!. $queue->svcnum.
75                                    qq!">$label</A>!;
76                                  } else {
77                                    '';
78                                  }
79                                },
80                                sub {
81                                  my $queue = shift;
82                                  my $access_user = $queue->access_user;
83                                  return $access_user ? $access_user->username : '';
84                                },
85                                sub {
86                                  my $queue = shift;
87                                  my $jobnum = $queue->jobnum;
88                                  my $status = $queue->status;
89                                  my $changable = $dangerous
90                                                  || ( ! $noactions
91                                                       && $status eq 'failed'
92                                                       || $status eq 'locked'
93                                                     );
94                                  if ( $changable ) {
95                                    $areboxes = 1;
96                                    qq!<INPUT NAME="jobnum$jobnum" TYPE="checkbox" VALUE="1">!;
97                                  } else {
98                                    '';
99                                  }
100                                },
101                              ],
102                  #'links' =>  [
103                  #              '',
104                  #              '',
105                  #              '',
106                  #              '',
107                  #              '',
108                  #              '', #$acct_link,
109                  #              '',
110                  #            ],
111                  'html_foot' => sub {
112                                   if ( $areboxes ) {
113                                     '<BR><INPUT TYPE="button" VALUE="select all" onClick="setAll(true)">'.
114                                     '<INPUT TYPE="button" VALUE="unselect all" onClick="setAll(false)">'.
115                                     '<BR><INPUT TYPE="submit" NAME="action" VALUE="retry selected">'.
116                                     '<INPUT TYPE="submit" NAME="action" VALUE="remove selected"><BR>'.
117                                     '<SCRIPT TYPE="text/javascript">'.
118                                     '  function setAll(setTo) { '.
119                                     '    theForm = document.jobForm;'.
120                                     '    for (i=0,n=theForm.elements.length;i<n;i++)'.
121                                     '      if (theForm.elements[i].name.indexOf("jobnum") != -1)'.
122                                     '        theForm.elements[i].checked = setTo;'.
123                                     '  }'.
124                                     '</SCRIPT>';
125                                   } else {
126                                     '';
127                                   }
128                                 },
129              
130 &>
131 <%init>
132
133 die "access denied"
134   unless $FS::CurrentUser::CurrentUser->access_right('Job queue');
135
136 my $hashref = {};
137
138 my $conf = new FS::Conf;
139 my $dangerous = $conf->exists('queue_dangerous_controls');
140
141 my $noactions = 0;
142
143 my $count_query = 'SELECT COUNT(*) FROM queue'; # + $hashref
144
145 my $areboxes = 0;
146
147 </%init>