use Net::SSH::ssh_cmd for all job queueing rather than local duplicated ssh subs
authorivan <ivan>
Wed, 20 Feb 2002 01:03:10 +0000 (01:03 +0000)
committerivan <ivan>
Wed, 20 Feb 2002 01:03:10 +0000 (01:03 +0000)
queue daemon updates: retry & remove links work, bubble up error message
to webinterface, link to svcnum & have job listings on view/svc_* pages,
closes: Bug#280

s/option/optionname/ schema change, dumb mysql, closes: Bug#334

20 files changed:
CREDITS
FS/FS/CGI.pm
FS/FS/Record.pm
FS/FS/queue.pm
FS/FS/svc_acct.pm
FS/FS/svc_domain.pm
FS/FS/svc_forward.pm
FS/bin/freeside-queued
README.1.4.0pre11
README.1.4.0pre8
bin/fs-setup
htetc/global.asa
htetc/handler.pl
httemplate/browse/queue.cgi
httemplate/index.html
httemplate/misc/queue.cgi [new file with mode: 0644]
httemplate/view/svc_acct.cgi
httemplate/view/svc_domain.cgi
httemplate/view/svc_forward.cgi
httemplate/view/svc_www.cgi

diff --git a/CREDITS b/CREDITS
index 6ad4a5f..2fd4078 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -58,7 +58,8 @@ Jeff Finucane <jeff@cmh.net> send in a bunch of bugfixes (for the sendmail
 export, cancel-unaudited.cgi), patches to support billing date modification,
 and probably other things too (sorry if I forgot them).  And yet even more
 bug squashing, thanks!  *and* he single-handedly implemented all the necessary
-work to get rid of svc_acct_sm and the "default domain"  thanks!!
+work to get rid of svc_acct_sm and the "default domain"  thanks!!  and rewrote
+the financials!  wow, thanks jeff!
 
 Kenny Elliott <kenny@neoserve.com> contributed ICRADIUS radreply table support,
 allowing attributes with ICRADIUS, helped fix many bugs, and some
@@ -80,7 +81,7 @@ Matt Peterson <matt@peterson.org> and Mack ? <mackn@mackn.net> tested
 the new features and contributed many bugfixes.
 
 Landel Telecom <http://www.landel.com/> sponsored shipping addresses and
-customer notes.
+customer notes, as well as an update of the CP provisioning.
 
 nikotel, Inc. <http://www.nikojet.com> sponsored the inclusion of
 customer-to-customer referrals in the web interface and signup server.
index 35d2e28..ee59b25 100644 (file)
@@ -5,7 +5,7 @@ use vars qw(@EXPORT_OK @ISA @header);
 use Exporter;
 use CGI;
 use URI::URL;
-use CGI::Carp qw(fatalsToBrowser);
+#use CGI::Carp qw(fatalsToBrowser);
 use FS::UID;
 
 @ISA = qw(Exporter);
@@ -45,7 +45,7 @@ Returns an HTML header.
 
 sub header {
   my($title,$menubar,$etc)=@_; #$etc is for things like onLoad= etc.
-  use Carp;
+  #use Carp;
   $etc = '' unless defined $etc;
 
   my $x =  <<END;
index 755cef8..020d14d 100644 (file)
@@ -59,13 +59,13 @@ FS::Record - Database record objects
     $hashref = $record->hashref;
 
     $error = $record->insert;
-    #$error = $record->add; #depriciated
+    #$error = $record->add; #deprecated
 
     $error = $record->delete;
-    #$error = $record->del; #depriciated
+    #$error = $record->del; #deprecated
 
     $error = $new_record->replace($old_record);
-    #$error = $new_record->rep($old_record); #depriciated
+    #$error = $new_record->rep($old_record); #deprecated
 
     $value = $record->unique('column');
 
@@ -974,6 +974,34 @@ sub ut_enum {
   return "Illegal (enum) field $field: ". $self->getfield($field);
 }
 
+=item ut_foreign_key COLUMN FOREIGN_TABLE FOREIGN_COLUMN
+
+Check/untaint a foreign column key.  Call a regular ut_ method (like ut_number)
+on the column first.
+
+=cut
+
+sub ut_foreign_key {
+  my( $self, $field, $table, $foreign ) = @_;
+  qsearchs($table, { $foreign => $self->getfield($field) })
+    or return "Can't find $field ". $self->getfield($field).
+              " in $table.$foreign";
+  '';
+}
+
+=item ut_foreign_keyn COLUMN FOREIGN_TABLE FOREIGN_COLUMN
+
+Like ut_foreign_key, except the null value is also allowed.
+
+=cut
+
+sub ut_foreign_keyn {
+  my( $self, $field, $table, $foreign ) = @_;
+  $self->getfield($field)
+    ? $self->ut_foreign_key($field, $table, $foreign)
+    : '';
+}
+
 =item fields [ TABLE ]
 
 This can be used as both a subroutine and a method call.  It returns a list
index 0967248..83ae171 100644 (file)
@@ -1,11 +1,15 @@
 package FS::queue;
 
 use strict;
-use vars qw( @ISA );
+use vars qw( @ISA @EXPORT_OK );
+use Exporter;
 use FS::Record qw( qsearch qsearchs dbh );
+#use FS::queue;
 use FS::queue_arg;
+use FS::cust_svc;
 
 @ISA = qw(FS::Record);
+@EXPORT_OK = qw( joblisting );
 
 =head1 NAME
 
@@ -39,6 +43,12 @@ FS::Record.  The following fields are currently supported:
 
 =item status - job status
 
+=item statustext - freeform text status message
+
+=item _date - UNIX timestamp
+
+=item svcnum - optional link to service (see L<FS::cust_svc>)
+
 =back
 
 =head1 METHODS
@@ -173,6 +183,9 @@ sub check {
     || $self->ut_anything('job')
     || $self->ut_numbern('_date')
     || $self->ut_enum('status',['', qw( new locked failed )])
+    || $self->ut_textn('statustext')
+    || $self->ut_numbern('svcnum')
+    || $self->ut_foreign_keyn('svcnum', 'cust_svc', 'svcnum')
   ;
   return $error if $error;
 
@@ -195,11 +208,86 @@ sub args {
                       );
 }
 
+=item cust_svc
+
+Returns the FS::cust_svc object associated with this job, if any.
+
+=cut
+
+sub cust_svc {
+  my $self = shift;
+  qsearchs('cust_svc', { 'svcnum' => $self->svcnum } );
+}
+
+=item joblisting HASHREF
+
+=cut
+
+sub joblisting {
+  my($hashref, $noactions) = @_;
+
+  use Date::Format;
+  use FS::CGI;
+
+  my $html = FS::CGI::table(). <<END;
+      <TR>
+        <TH COLSPAN=2>Job</TH>
+        <TH>Args</TH>
+        <TH>Date</TH>
+        <TH>Status</TH>
+        <TH>Account</TH>
+      </TR>
+END
+
+  my $p = FS::CGI::popurl(2);
+  foreach my $queue ( sort { 
+    $a->getfield('jobnum') <=> $b->getfield('jobnum')
+  } qsearch( 'queue', $hashref ) ) {
+    my $hashref = $queue->hashref;
+    my $jobnum = $queue->jobnum;
+    my $args = join(' ', $queue->args);
+    my $date = time2str( "%a %b %e %T %Y", $queue->_date );
+    my $status = $queue->status;
+    $status .= ': '. $queue->statustext if $queue->statustext;
+    if ( ! $noactions && $status =~ /^failed/ || $status =~ /^locked/ ) {
+      $status .=
+        qq! ( <A HREF="$p/misc/queue.cgi?jobnum=$jobnum&action=new">retry</A> |!.
+        qq! <A HREF="$p/misc/queue.cgi?jobnum=$jobnum&action=del">remove </A> )!;
+    }
+    my $cust_svc = $queue->cust_svc;
+    my $account;
+    if ( $cust_svc ) {
+      my $table = $cust_svc->part_svc->svcdb;
+      my $label = ( $cust_svc->label )[1];
+      $account = qq!<A HREF="../view/$table.cgi?!. $queue->svcnum.
+                 qq!">$label</A>!;
+    } else {
+      $account = '';
+    }
+    $html .= <<END;
+      <TR>
+        <TD>$jobnum</TD>
+        <TD>$hashref->{job}</TD>
+        <TD>$args</TD>
+        <TD>$date</TD>
+        <TD>$status</TD>
+        <TD>$account</TD>
+      </TR>
+END
+
+}
+
+  $html .= '</TABLE>';
+
+  $html;
+
+}
+
 =back
 
 =head1 VERSION
 
-$Id: queue.pm,v 1.3 2001-09-11 12:25:55 ivan Exp $
+$Id: queue.pm,v 1.4 2002-02-20 01:03:09 ivan Exp $
 
 =head1 BUGS
 
index 65a58fc..2f327a3 100644 (file)
@@ -281,7 +281,10 @@ sub insert {
     $self->shell,
   );
   if ( $username && $uid && $dir && $shellmachine && ! $nossh_hack ) {
-    my $queue = new FS::queue { 'job' => 'FS::svc_acct::ssh' };
+    my $queue = new FS::queue {
+      'svcnum' => $self->svcnum,
+      'job' => 'Net::SSH::ssh_cmd',
+    };
     $error = $queue->insert("root\@$shellmachine", eval qq("$useradd") );
     if ( $error ) {
       $dbh->rollback if $oldAutoCommit;
@@ -290,7 +293,10 @@ sub insert {
   }
 
   if ( $cyrus_server ) {
-    my $queue = new FS::queue { 'job' => 'FS::svc_acct::cyrus_insert' };
+    my $queue = new FS::queue {
+      'svcnum' => $self->svcnum,
+      'job'    => 'FS::svc_acct::cyrus_insert',
+    };
     $error = $queue->insert($self->username, $self->quota);
     if ( $error ) {
       $dbh->rollback if $oldAutoCommit;
@@ -299,7 +305,10 @@ sub insert {
   }
 
   if ( $cp_server ) {
-    my $queue = new FS::queue { 'job' => 'FS::svc_acct::cp_insert' };
+    my $queue = new FS::queue {
+      'svcnum' => $self->svcnum,
+      'job'    => 'FS::svc_acct::cp_insert'
+    };
     $error = $queue->insert($self->username, $self->_password);
     if ( $error ) {
       $dbh->rollback if $oldAutoCommit;
@@ -310,7 +319,10 @@ sub insert {
   if ( $icradius_dbh ) {
 
     my $radcheck_queue =
-      new FS::queue { 'job' => 'FS::svc_acct::icradius_rc_insert' };
+      new FS::queue {
+      'svcnum' => $self->svcnum,
+      'job' => 'FS::svc_acct::icradius_rc_insert'
+    };
     $error = $radcheck_queue->insert( $self->username,
                                       $self->_password,
                                       $self->radius_check
@@ -321,7 +333,10 @@ sub insert {
     }
 
     my $radreply_queue =
-      new FS::queue { 'job' => 'FS::svc_acct::icradius_rr_insert' };
+      new FS::queue { 
+      'svcnum' => $self->svcnum,
+      'job' => 'FS::svc_acct::icradius_rr_insert'
+    };
     $error = $radreply_queue->insert( $self->username,
                                       $self->_password,
                                       $self->radius_reply
@@ -542,7 +557,7 @@ sub delete {
     $self->dir,
   );
   if ( $username && $shellmachine && ! $nossh_hack ) {
-    my $queue = new FS::queue { 'job' => 'FS::svc_acct::ssh' };
+    my $queue = new FS::queue { 'job' => 'Net::SSH::ssh_cmd' };
     $error = $queue->insert("root\@$shellmachine", eval qq("$userdel") );
     if ( $error ) {
       $dbh->rollback if $oldAutoCommit;
@@ -728,7 +743,10 @@ sub replace {
     $new->getfield('gid'),
   );
   if ( $old_dir && $new_dir && $old_dir ne $new_dir && ! $nossh_hack ) {
-    my $queue = new FS::queue { 'job' => 'FS::svc_acct::ssh' };
+    my $queue = new FS::queue { 
+      'svcnum' => $new->svcnum,
+      'job' => 'Net::SSH::ssh_cmd'
+    };
     $error = $queue->insert("root\@$shellmachine", eval qq("$usermod") );
     if ( $error ) {
       $dbh->rollback if $oldAutoCommit;
@@ -737,7 +755,10 @@ sub replace {
   }
 
   if ( $cp_server && $old->username ne $new->username ) {
-    my $queue = new FS::queue { 'job' => 'FS::svc_acct::cp_rename' };
+    my $queue = new FS::queue { 
+      'svcnum' => $new->svcnum,
+      'job' => 'FS::svc_acct::cp_rename'
+    };
     $error = $queue->insert( $old->username, $new->username );
     if ( $error ) {
       $dbh->rollback if $oldAutoCommit;
@@ -746,7 +767,10 @@ sub replace {
   }
 
   if ( $cp_server && $old->_password ne $new->_password ) {
-    my $queue = new FS::queue { 'job' => 'FS::svc_acct::cp_change' };
+    my $queue = new FS::queue {  
+      'svcnum' => $new->svcnum,
+      'job' => 'FS::svc_acct::cp_change'
+    };
     $error = $queue->insert( $new->username, $new->_password );
     if ( $error ) {
       $dbh->rollback if $oldAutoCommit;
@@ -755,7 +779,10 @@ sub replace {
   }
 
   if ( $icradius_dbh ) {
-    my $queue = new FS::queue { 'job' => 'FS::svc_acct::icradius_rc_replace' };
+    my $queue = new FS::queue {  
+      'svcnum' => $new->svcnum,
+      'job' => 'FS::svc_acct::icradius_rc_replace'
+    };
     $error = $queue->insert( $new->username,
                              $new->_password,
                            );
@@ -1164,34 +1191,6 @@ sub seconds_since {
   $self->cust_svc->seconds_since(@_);
 }
 
-=item ssh
-
-=cut
-
-sub ssh {
-  my ( $host, @cmd_and_args ) = @_;
-
-  use IO::File;
-  my $reader = IO::File->new();
-  my $writer = IO::File->new();
-  my $error = IO::File->new();
-
-  &Net::SSH::sshopen3( $host, $reader, $writer, $error, @cmd_and_args) or die $!;
-
-  local $/ = undef;
-  my $output_stream = <$writer>;
-  my $error_stream = <$error>;
-  if ( length $error_stream ) {
-    #warn "[FS::svc_acct::ssh] STDERR $error_stream";
-    die "[FS::svc_acct::ssh] STDERR $error_stream";
-  }
-  if ( length $output_stream ) {
-    warn "[FS::svc_acct::ssh] STDOUT $output_stream";
-  }
-
-#  &Net::SSH::ssh(@args,">>/usr/local/etc/freeside/sshoutput 2>&1");
-}
-
 =back
 
 =head1 BUGS
index d0f0e11..84a1029 100644 (file)
@@ -241,7 +241,10 @@ sub insert {
         $svc_acct->dir,
       );
   
-    my $queue = new FS::queue { 'job' => 'FS::svc_domain::ssh' };
+    my $queue = new FS::queue {
+      'svcnum' => $self->svcnum,
+      'job'    => 'Net::SSH::ssh_cmd',
+    };
     $error = $queue->insert("root\@$qshellmachine", "[ -e $dir/.qmail-$qdomain-default ] || { touch $dir/.qmail-$qdomain-default; chown $uid:$gid $dir/.qmail-$qdomain-default; }" );
 
     }
@@ -250,36 +253,6 @@ sub insert {
   ''; #no error
 }
 
-=item ssh
-
-=cut
-
-#false laziness with FS::svc_acct::ssh
-sub ssh {
-  my ( $host, @cmd_and_args ) = @_;
-
-  use IO::File;
-  my $reader = IO::File->new();
-  my $writer = IO::File->new();
-  my $error = IO::File->new();
-
-  &Net::SSH::sshopen3( $host, $reader, $writer, $error, @cmd_and_args) or die $!;
-
-  local $/ = undef;
-  my $output_stream = <$writer>;
-  my $error_stream = <$error>;
-  if ( length $error_stream ) {
-    #warn "[FS::svc_acct::ssh] STDERR $error_stream";
-    die "[FS::svc_domain::ssh] STDERR $error_stream";
-  }
-  if ( length $output_stream ) {
-    warn "[FS::svc_domain::ssh] STDOUT $output_stream";
-  }
-
-#  &Net::SSH::ssh(@args,">>/usr/local/etc/freeside/sshoutput 2>&1");
-}
-
-
 =item delete
 
 Deletes this domain from the database.  If there is an error, returns the
@@ -451,7 +424,7 @@ sub submit_internic {
 
 =head1 VERSION
 
-$Id: svc_domain.pm,v 1.23 2002-02-09 18:09:30 ivan Exp $
+$Id: svc_domain.pm,v 1.24 2002-02-20 01:03:09 ivan Exp $
 
 =head1 BUGS
 
index 7e0a4fd..12f8b92 100644 (file)
@@ -140,7 +140,11 @@ sub insert {
     
   foreach my $vpopmailmachine ( @vpopmailmachines ) {
     my($machine, $vpopdir, $vpopuid, $vpopgid) = split(/\s+/, $vpopmailmachine);
-    my $queue = new FS::queue { 'job' => 'Net::SSH::ssh_cmd' };  # should be neater
+    my $queue = new FS::queue {
+      'svcnum' => $self->svcnum,
+      'job'    => 'Net::SSH::ssh_cmd',
+    };
+    # should be neater
     my $error = $queue->insert("root\@$machine","[ -d $vpopdir/domains/$domain/$username ] && { echo \"$destination\" >> $vpopdir/domains/$domain/$username/.qmail; chown $vpopuid:$vpopgid $vpopdir/domains/$domain/$username/.qmail; }") 
       unless $nossh_hack;
     if ( $error ) {
@@ -209,7 +213,8 @@ sub delete {
   foreach my $vpopmailmachine ( @vpopmailmachines ) {
     my($machine, $vpopdir, $vpopuid, $vpopgid) =
       split(/\s+/, $vpopmailmachine);
-    my $queue = new FS::queue { 'job' => 'Net::SSH::ssh_cmd' };  # should be neater
+    my $queue = new FS::queue { 'job' => 'Net::SSH::ssh_cmd' };
+    # should be neater
     my $error = $queue->insert("root\@$machine",
       "sed -e '/^$destination/d' " .
         "< $vpopdir/domains/$domain/$username/.qmail" .
@@ -302,7 +307,11 @@ sub replace {
   foreach my $vpopmailmachine ( @vpopmailmachines ) {
     my($machine, $vpopdir, $vpopuid, $vpopgid) =
       split(/\s+/, $vpopmailmachine);
-    my $queue = new FS::queue { 'job' => 'Net::SSH::ssh_cmd' };  # should be neater
+    my $queue = new FS::queue {
+      'svcnum' => $new->svcnum,
+      'job'    => 'Net::SSH::ssh_cmd',
+    };
+    # should be neater
     my $error = $queue->insert("root\@$machine",
       "sed -e '/^$destination/d' " .
         "< $vpopdir/domains/$old_domain/$old_username/.qmail" .
@@ -332,7 +341,11 @@ sub replace {
   
   foreach my $vpopmailmachine ( @vpopmailmachines ) {
     my($machine, $vpopdir, $vpopuid, $vpopgid) = split(/\s+/, $vpopmailmachine);
-    my $queue = new FS::queue { 'job' => 'Net::SSH::ssh_cmd' };  # should be neater
+    my $queue = new FS::queue {
+      'svcnum' => $new->svcnum,
+      'job'    => 'Net::SSH::ssh_cmd',
+    };
+    # should be neater
     my $error = $queue->insert("root\@$machine","[ -d $vpopdir/domains/$domain/$username ] && { echo \"$destination\" >> $vpopdir/domains/$domain/$username/.qmail; chown $vpopuid:$vpopgid $vpopdir/domains/$domain/$username/.qmail; }") 
       unless $nossh_hack;
     if ( $error ) {
@@ -439,7 +452,7 @@ sub dstsvc_acct {
 
 =head1 VERSION
 
-$Id: svc_forward.pm,v 1.10 2002-02-17 19:07:32 jeff Exp $
+$Id: svc_forward.pm,v 1.11 2002-02-20 01:03:09 ivan Exp $
 
 =head1 BUGS
 
index 87e3cb4..56475d0 100644 (file)
@@ -14,7 +14,7 @@ use FS::queue;
 # no autoloading just yet
 use FS::cust_main;
 use FS::svc_acct;
-use Net::SSH;
+use Net::SSH 0.05;
 
 my $pid_file = '/var/run/freeside-queued.pid';
 
@@ -69,6 +69,7 @@ while (1) {
     warn "WARNING: can't fork: $!\n";
     my %hash = $job->hash;
     $hash{'status'} = 'failed';
+    $hash{'statustext'} = "[freeside-queued] can't fork: $!";
     my $ljob = new FS::queue ( \%hash );
     my $error = $ljob->replace($job);
     die $error if $error;
@@ -89,6 +90,7 @@ while (1) {
       warn "job $eval failed";
       my %hash = $ljob->hash;
       $hash{'status'} = 'failed';
+      $hash{'statustext'} = $@;
       my $fjob = new FS::queue( \%hash );
       my $error = $fjob->replace($ljob);
       die $error if $error;
index c3a64d7..5a4bced 100644 (file)
@@ -1,2 +1,33 @@
-install rsync
+the following is necessary to upgrade from 1.4.0pre ( 9 or 10 )
+to 1.4.0pre11
+
+if you're upgrading from before 1.4.0pre11 see README.1.4.0pre9 first!
+
+if you're upgrading from 1.3.1 follow the instructions in
+httemplate/docs/upgrade8.html instead
+
+----
+
+install rsync <http://rsync.samba.org/>
+
+install the FS perl modules and httemplate as per install.html or upgrade8.html
+
+ALTER TABLE queue ADD svcnum int NULL;
+ALTER TABLE queue ADD statustext text NULL;
+CREATE INDEX queue1 ON queue ( svcnum );
+CREATE INDEX queue2 ON queue ( status );
+
+DROP TABLE part_export_option;
+CREATE TABLE part_export_option (
+  optionnum int primary key,
+  exportnum int not null,
+  optionname varchar(80) not null,
+  optionvalue text NULL
+);
+CREATE INDEX part_export_option1 ON part_export_option ( exportnum );
+CREATE INDEX part_export_option2 ON part_export_option ( optionname );
+
+Run bin/dbdef-create
+
+Restart Apache and freeside-queued
 
index ef20b29..7ddd7e2 100644 (file)
@@ -50,11 +50,11 @@ CREATE INDEX part_export2 ON part_export ( exporttype );
 CREATE TABLE part_export_option (
   optionnum int primary key,
   exportnum int not null,
-  option varchar(80) not null,
+  optionname varchar(80) not null,
   optionvalue text NULL
 );
 CREATE INDEX part_export_option1 ON part_export_option ( exportnum );
-CREATE INDEX part_export_option2 ON part_export_option ( option );
+CREATE INDEX part_export_option2 ON part_export_option ( optionname );
 
 ALTER TABLE cust_bill ADD closed char(1) NULL;
 ALTER TABLE cust_pay ADD closed char(1) NULL;
index 7c716d3..48d28c6 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 #
-# $Id: fs-setup,v 1.77 2002-02-12 05:58:42 ivan Exp $
+# $Id: fs-setup,v 1.78 2002-02-20 01:03:09 ivan Exp $
 
 #to delay loading dbdef until we're ready
 BEGIN { $FS::Record::setup_hack = 1; }
@@ -856,10 +856,12 @@ sub tables_hash_hack {
         'job', 'text', '', '',
         '_date', 'int', '', '',
         'status', 'varchar', '', $char_d,
+        'statustext', 'text', '', '',
+        'svcnum', 'int', '', '',
       ],
       'primary_key' => 'jobnum',
       'unique'      => [],
-      'index'       => [],
+      'index'       => [ [ 'svcnum' ], [ 'status' ] ],
     },
 
     'queue_arg' => {
@@ -890,12 +892,12 @@ sub tables_hash_hack {
       'columns' => [
         'optionnum', 'int', '', '',
         'exportnum', 'int', '', '',
-        'option', 'varchar', '', $char_d,
+        'optionname', 'varchar', '', $char_d,
         'optionvalue', 'text', 'NULL', '',
       ],
       'primary_key' => 'optionnum',
       'unique'      => [],
-      'index'       => [ [ 'exportnum' ], [ 'option' ] ],
+      'index'       => [ [ 'exportnum' ], [ 'optionname' ] ],
     },
 
   );
index ce3bc27..339f01d 100644 (file)
@@ -35,7 +35,7 @@ use FS::part_referral;
 use FS::part_svc;
 use FS::pkg_svc;
 use FS::port;
-use FS::queue;
+use FS::queue qw(joblisting);
 use FS::raddb;
 use FS::session;
 use FS::svc_acct;
index cac9004..680d11e 100644 (file)
@@ -92,7 +92,7 @@ sub handler
       use FS::part_svc;
       use FS::pkg_svc;
       use FS::port;
-      use FS::queue;
+      use FS::queue qw(joblisting);
       use FS::raddb;
       use FS::session;
       use FS::svc_acct;
index 7fce1f5..b53c140 100755 (executable)
@@ -1,47 +1,7 @@
 <!-- mason kludge -->
 <%
 
-print header("Job Queue", menubar(
-  'Main Menu' => $p,
-#  'Add new referral' => "../edit/part_referral.cgi",
-)), &table(), <<END;
-      <TR>
-        <TH COLSPAN=2>Job</TH>
-        <TH>Args</TH>
-        <TH>Date</TH>
-        <TH>Status</TH>
-      </TR>
-END
-
-foreach my $queue ( sort { 
-  $a->getfield('jobnum') <=> $b->getfield('jobnum')
-} qsearch('queue',{}) ) {
-  my($hashref)=$queue->hashref;
-  my $jobnum = $hashref->{jobnum};
-  my $args = join(' ', $queue->args);
-  my $date = time2str( "%a %b %e %T %Y", $queue->_date );
-  my $status = $hashref->{status};
-  if ( $status eq 'failed' || $status eq 'locked' ) {
-    $status .=
-      qq! ( <A HREF="$p/edit/queue.cgi?jobnum=$jobnum&action=new">retry</A> |!.
-      qq! <A HREF="$p/edit/queue.cgi?jobnum$jobnum&action=del">remove </A> )!;
-  }
-  print <<END;
-      <TR>
-        <TD>$jobnum</TD>
-        <TD>$hashref->{job}</TD>
-        <TD>$args</TD>
-        <TD>$date</TD>
-        <TD>$status</TD>
-      </TR>
-END
-
-}
-
-print <<END;
-    </TABLE>
-  </BODY>
-</HTML>
-END
+print header("Job Queue", menubar( 'Main Menu' => $p, )).
+      joblisting({}). '</BODY></HTML>';
 
 %>
index dd08c4f..f4bb658 100644 (file)
@@ -66,7 +66,7 @@
               <LI>120 day open invoices (<A HREF="search/cust_bill.cgi?OPEN120_invnum">by invoice number</A>) (<A HREF="search/cust_bill.cgi?OPEN120_date">by date</A>) (<A HREF="search/cust_bill.cgi?OPEN120_custnum">by customer number</A>)
               <LI>all invoices (<A HREF="search/cust_bill.cgi?invnum">by invoice number</A>) (<A HREF="search/cust_bill.cgi?date">by date</A>) (<A HREF="search/cust_bill.cgi?custnum">by customer number</A>)
             </UL>
-      <BR><CENTER><HR WIDTH="87%" NOSHADE></CENTER><BR>
+      <BR><CENTER><HR WIDTH="94%" NOSHADE></CENTER><BR>
       <A NAME="admin">Administration</a>
         <ul>
           <LI><A HREF="browse/part_pkg.cgi">View/Edit package definitions</A>
       <BR>
       <A HREF="browse/nas.cgi">View active NAS ports</A>
       <BR><A HREF="browse/queue.cgi">View pending job queue</A>
-      <BR><BR><CENTER><HR WIDTH="87%" NOSHADE></CENTER><BR>
+      <BR><BR><CENTER><HR WIDTH="94%" NOSHADE></CENTER><BR>
       <A NAME="config" HREF="config/config-view.cgi">Configuration</a><!-- - <font size="+2" color="#ff0000">start here</font> -->
       <BR><BR><A NAME="admin">Administration</a>
         <ul>
diff --git a/httemplate/misc/queue.cgi b/httemplate/misc/queue.cgi
new file mode 100644 (file)
index 0000000..7e962d4
--- /dev/null
@@ -0,0 +1,25 @@
+<%
+
+$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";
+my $action = $1;
+
+if ( $action eq '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 'del' ) {
+  my $error = $job->delete;
+  die $error if $error;
+}
+
+print $cgi->redirect(popurl(2). "browse/queue.cgi");
+
+%>
index 90ca1a2..d1c6157 100755 (executable)
@@ -129,6 +129,8 @@ if ($svc_acct->slipip) {
   print "<TR><TH COLSPAN=2>(No SLIP/PPP account)</TH></TR>";
 }
 
-print "</TABLE></TD></TR></TABLE></BODY></HTML>";
+print "</TABLE></TD></TR></TABLE>".
+      '<BR>'. joblisting({'svcnum'=>$svcnum}, 1).
+      "</BODY></HTML>";
 
 %>
index f086cda..61194a2 100755 (executable)
@@ -55,8 +55,8 @@ foreach my $domain_record ( qsearch('domain_record', { svcnum => $svcnum } ) ) {
         '<td>'. $domain_record->recaf. ' '. $domain_record->rectype. '</td>'.
         '<td>'. $domain_record->recdata. '</td></tr>';
 }
-print '</table>';
-
-print '</BODY></HTML>';
+print '</table>'.
+      '<BR>'. joblisting({'svcnum'=>$svcnum}, 1).
+      '</BODY></HTML>';
 
 %>
index cafb9e5..8d2afc8 100755 (executable)
@@ -52,10 +52,11 @@ if ($dstsvc) {
   $destination = $dst;
 }
 
-print qq!<A HREF="${p}edit/svc_forward.cgi?$svcnum">Edit this information</A>!,
-      "<BR>Service #$svcnum",
-      "<BR>Service: <B>$svc</B>",
-      qq!<BR>Mail to <B>$source</B> forwards to <B>$destination</B> mailbox.!,
+print qq!<A HREF="${p}edit/svc_forward.cgi?$svcnum">Edit this information</A>!.
+      "<BR>Service #$svcnum".
+      "<BR>Service: <B>$svc</B>".
+      qq!<BR>Mail to <B>$source</B> forwards to <B>$destination</B> mailbox.!.
+      '<BR>'. joblisting({'svcnum'=>$svcnum}, 1).
       '</BODY></HTML>'
 ;
 
index a82921f..70a7a1b 100644 (file)
@@ -38,9 +38,10 @@ print header('Website View', menubar(
           "${p}misc/cancel-unaudited.cgi?$svcnum" )
   ),
   "Main menu" => $p,
-)),
-      "Service #$svcnum",
-      qq!<BR>Website name: <B><A HREF="http://$www">$www</A></B>!,
-      '</BODY></HTML>',                
+)).
+      "Service #$svcnum".
+      qq!<BR>Website name: <B><A HREF="http://$www">$www</A></B>!.
+      '<BR>'. joblisting({'svcnum'=>$svcnum}, 1).
+      '</BODY></HTML>'
 ;
 %>