diff options
| author | ivan <ivan> | 2002-02-20 01:03:10 +0000 | 
|---|---|---|
| committer | ivan <ivan> | 2002-02-20 01:03:10 +0000 | 
| commit | 8f42b751aebda2e7dce2c363bed6f1e15b411b1d (patch) | |
| tree | 942c30415b1e1683dec03dd62dcc24d575f7de46 | |
| parent | 47bc56487b4aebf3e415767a053dc049fe4a28d4 (diff) | |
use Net::SSH::ssh_cmd for all job queueing rather than local duplicated ssh subs
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
| -rw-r--r-- | CREDITS | 5 | ||||
| -rw-r--r-- | FS/FS/CGI.pm | 4 | ||||
| -rw-r--r-- | FS/FS/Record.pm | 34 | ||||
| -rw-r--r-- | FS/FS/queue.pm | 92 | ||||
| -rw-r--r-- | FS/FS/svc_acct.pm | 75 | ||||
| -rw-r--r-- | FS/FS/svc_domain.pm | 37 | ||||
| -rw-r--r-- | FS/FS/svc_forward.pm | 23 | ||||
| -rw-r--r-- | FS/bin/freeside-queued | 4 | ||||
| -rw-r--r-- | README.1.4.0pre11 | 33 | ||||
| -rw-r--r-- | README.1.4.0pre8 | 4 | ||||
| -rwxr-xr-x | bin/fs-setup | 10 | ||||
| -rw-r--r-- | htetc/global.asa | 2 | ||||
| -rw-r--r-- | htetc/handler.pl | 2 | ||||
| -rwxr-xr-x | httemplate/browse/queue.cgi | 44 | ||||
| -rw-r--r-- | httemplate/index.html | 4 | ||||
| -rw-r--r-- | httemplate/misc/queue.cgi | 25 | ||||
| -rwxr-xr-x | httemplate/view/svc_acct.cgi | 4 | ||||
| -rwxr-xr-x | httemplate/view/svc_domain.cgi | 6 | ||||
| -rwxr-xr-x | httemplate/view/svc_forward.cgi | 9 | ||||
| -rw-r--r-- | httemplate/view/svc_www.cgi | 9 | 
20 files changed, 276 insertions, 150 deletions
@@ -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. diff --git a/FS/FS/CGI.pm b/FS/FS/CGI.pm index 35d2e2839..ee59b259f 100644 --- a/FS/FS/CGI.pm +++ b/FS/FS/CGI.pm @@ -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; diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 755cef830..020d14d8f 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -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 diff --git a/FS/FS/queue.pm b/FS/FS/queue.pm index 09672480b..83ae17189 100644 --- a/FS/FS/queue.pm +++ b/FS/FS/queue.pm @@ -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 diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index 65a58fc98..2f327a3d3 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -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 diff --git a/FS/FS/svc_domain.pm b/FS/FS/svc_domain.pm index d0f0e11a8..84a102911 100644 --- a/FS/FS/svc_domain.pm +++ b/FS/FS/svc_domain.pm @@ -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 diff --git a/FS/FS/svc_forward.pm b/FS/FS/svc_forward.pm index 7e0a4fd99..12f8b9236 100644 --- a/FS/FS/svc_forward.pm +++ b/FS/FS/svc_forward.pm @@ -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 diff --git a/FS/bin/freeside-queued b/FS/bin/freeside-queued index 87e3cb422..56475d059 100644 --- a/FS/bin/freeside-queued +++ b/FS/bin/freeside-queued @@ -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; diff --git a/README.1.4.0pre11 b/README.1.4.0pre11 index c3a64d7b4..5a4bcedc7 100644 --- a/README.1.4.0pre11 +++ b/README.1.4.0pre11 @@ -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 diff --git a/README.1.4.0pre8 b/README.1.4.0pre8 index ef20b298f..7ddd7e292 100644 --- a/README.1.4.0pre8 +++ b/README.1.4.0pre8 @@ -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; diff --git a/bin/fs-setup b/bin/fs-setup index 7c716d35e..48d28c6f0 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -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' ] ],      },    ); diff --git a/htetc/global.asa b/htetc/global.asa index ce3bc27c8..339f01dae 100644 --- a/htetc/global.asa +++ b/htetc/global.asa @@ -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; diff --git a/htetc/handler.pl b/htetc/handler.pl index cac90044d..680d11ec8 100644 --- a/htetc/handler.pl +++ b/htetc/handler.pl @@ -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; diff --git a/httemplate/browse/queue.cgi b/httemplate/browse/queue.cgi index 7fce1f5df..b53c1402d 100755 --- a/httemplate/browse/queue.cgi +++ b/httemplate/browse/queue.cgi @@ -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>';  %> diff --git a/httemplate/index.html b/httemplate/index.html index dd08c4fa7..f4bb6581c 100644 --- a/httemplate/index.html +++ b/httemplate/index.html @@ -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> @@ -133,7 +133,7 @@        <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 index 000000000..7e962d498 --- /dev/null +++ b/httemplate/misc/queue.cgi @@ -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"); + +%> diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi index 90ca1a240..d1c61576d 100755 --- a/httemplate/view/svc_acct.cgi +++ b/httemplate/view/svc_acct.cgi @@ -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>";  %> diff --git a/httemplate/view/svc_domain.cgi b/httemplate/view/svc_domain.cgi index f086cda1a..61194a26d 100755 --- a/httemplate/view/svc_domain.cgi +++ b/httemplate/view/svc_domain.cgi @@ -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>';  %> diff --git a/httemplate/view/svc_forward.cgi b/httemplate/view/svc_forward.cgi index cafb9e5b8..8d2afc823 100755 --- a/httemplate/view/svc_forward.cgi +++ b/httemplate/view/svc_forward.cgi @@ -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>'  ; diff --git a/httemplate/view/svc_www.cgi b/httemplate/view/svc_www.cgi index a82921f1b..70a7a1be4 100644 --- a/httemplate/view/svc_www.cgi +++ b/httemplate/view/svc_www.cgi @@ -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>'  ;  %>  | 
