X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fqueue.pm;h=7a38a6eefaa39e5538c0765867a035daf416704d;hb=8fe83dcb8807a86209625a5aab7e574073f0a907;hp=09672480b7f021ddb2fb30536e9407390c4b5571;hpb=148727c4b03abc9b73149c101afcc4f3fff57a73;p=freeside.git diff --git a/FS/FS/queue.pm b/FS/FS/queue.pm index 09672480b..7a38a6eef 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) + =back =head1 METHODS @@ -68,6 +78,7 @@ created (see L). =cut +#false laziness w/part_export.pm sub insert { my $self = shift; @@ -173,9 +184,14 @@ 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') ; return $error if $error; + $error = $self->ut_foreign_keyn('svcnum', 'cust_svc', 'svcnum'); + $self->svcnum('') if $error; + $self->status('new') unless $self->status; $self->_date(time) unless $self->_date; @@ -195,11 +211,94 @@ 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 NOACTIONS + +=cut + +sub joblisting { + my($hashref, $noactions) = @_; + + use Date::Format; + use FS::CGI; + + my @queue = qsearch( 'queue', $hashref ); + return '' unless scalar(@queue); + + my $html = FS::CGI::table(). < + Job + Args + Date + Status +END + $html .= 'Account' unless $hashref->{svcnum}; + $html .= ''; + + my $p = FS::CGI::popurl(2); + foreach my $queue ( sort { + $a->getfield('jobnum') <=> $b->getfield('jobnum') + } @queue ) { + my $queue_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! ( retry |!. + qq! remove )!; + } + my $cust_svc = $queue->cust_svc; + + $html .= < + $jobnum + $queue_hashref->{job} + $args + $date + $status +END + + unless ( $hashref->{svcnum} ) { + my $account; + if ( $cust_svc ) { + my $table = $cust_svc->part_svc->svcdb; + my $label = ( $cust_svc->label )[1]; + $account = qq!$label!; + } else { + $account = ''; + } + $html .= "$account"; + } + + $html .= ''; + +} + + $html .= ''; + + $html; + +} + =back =head1 VERSION -$Id: queue.pm,v 1.3 2001-09-11 12:25:55 ivan Exp $ +$Id: queue.pm,v 1.8 2002-03-23 16:16:00 ivan Exp $ =head1 BUGS