combine ticket notification scrips, #15353
[freeside.git] / httemplate / search / queue.html
index 132c051..1c12470 100644 (file)
@@ -1,23 +1,10 @@
-<%
-
-my $hashref = {};
-
-my $conf = new FS::Conf;
-my $dangerous = $conf->exists('queue_dangerous_controls');
-
-my $noactions = 0;
-
-my $count_query = 'SELECT COUNT(*) FROM queue'; # + $hashref
-
-my $areboxes = 0;
-
-%><%= include( 'elements/search.html',
+<% include( 'elements/search.html',
                  'title'       => 'Job Queue',
-                 'menubar'     => [ 'Main menu' => $p, ],
                  'name'        => 'jobs',
+                'html_form'   => qq!<FORM NAME="jobForm" ACTION="$p/misc/queue.cgi" METHOD="POST">!,
                  'query'       => { 'table'     => 'queue',
                                     'hashref'   => $hashref,
-                                    'extra_sql' => 'ORDER BY jobnum',
+                                    'order_by' => 'ORDER BY jobnum',
                                   },
                  'count_query' => $count_query,
                  'header' => [ '#',
@@ -63,10 +50,14 @@ my $areboxes = 0;
                                                  || ( ! $noactions
                                                       && $status =~ /^failed/
                                                       || $status =~ /^locked/
+                                                      || $status =~ /^done/
                                                     );
                                  if ( $changable ) {
+                                   $status .= qq! (!;
+                                   $status .=
+                                     qq! &nbsp;<A HREF="$p/misc/queue.cgi?jobnum=$jobnum&action=new">retry</A>&nbsp;|!
+                                     unless $status =~ /^done/;
                                    $status .=
-                                     qq! (&nbsp;<A HREF="$p/misc/queue.cgi?jobnum=$jobnum&action=new">retry</A>&nbsp;|!.
                                      qq!&nbsp;<A HREF="$p/misc/queue.cgi?jobnum=$jobnum&action=del">remove</A>&nbsp;)!;
                                  }
                                  $status;
@@ -113,8 +104,18 @@ my $areboxes = 0;
                  #            ],
                  'html_foot' => sub {
                                   if ( $areboxes ) {
+                                    '<BR><INPUT TYPE="button" VALUE="select all" onClick="setAll(true)">'.
+                                    '<INPUT TYPE="button" VALUE="unselect all" onClick="setAll(false)">'.
                                     '<BR><INPUT TYPE="submit" NAME="action" VALUE="retry selected">'.
-                                    '<INPUT TYPE="submit" NAME="action" VALUE="remove selected"><BR>';
+                                    '<INPUT TYPE="submit" NAME="action" VALUE="remove selected"><BR>'.
+                                    '<SCRIPT TYPE="text/javascript">'.
+                                    '  function setAll(setTo) { '.
+                                    '    theForm = document.jobForm;'.
+                                    '    for (i=0,n=theForm.elements.length;i<n;i++)'.
+                                    '      if (theForm.elements[i].name.indexOf("jobnum") != -1)'.
+                                    '        theForm.elements[i].checked = setTo;'.
+                                    '  }'.
+                                    '</SCRIPT>';
                                   } else {
                                     '';
                                   }
@@ -122,3 +123,20 @@ my $areboxes = 0;
              )
 
 %>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Job queue');
+
+my $hashref = {};
+
+my $conf = new FS::Conf;
+my $dangerous = $conf->exists('queue_dangerous_controls');
+
+my $noactions = 0;
+
+my $count_query = 'SELECT COUNT(*) FROM queue'; # + $hashref
+
+my $areboxes = 0;
+
+</%init>