diff options
author | ivan <ivan> | 2009-02-22 08:41:28 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-02-22 08:41:28 +0000 |
commit | 52b311cb03ee6714c2ea8d108efdfef86c2c3e1d (patch) | |
tree | 3b9d3118d29a1018c9d16375a1a7707b799b48bc | |
parent | 8690a879634b3a9a90e00e4359b167967065c237 (diff) |
add agent type list to package def browse, RT#4880
-rw-r--r-- | FS/FS/part_pkg.pm | 12 | ||||
-rw-r--r-- | FS/FS/type_pkgs.pm | 21 | ||||
-rwxr-xr-x | httemplate/browse/part_pkg.cgi | 35 |
3 files changed, 60 insertions, 8 deletions
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index 3308eadf4..f7c56f3dd 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -560,6 +560,18 @@ packages. =cut +=item type_pkgs + +Returns all FS::type_pkgs objects (see L<FS::type_pkgs>) for this package +definition. + +=cut + +sub type_pkgs { + my $self = shift; + qsearch('type_pkgs', { 'pkgpart' => $self->pkgpart } ); +} + sub pkg_svc { my $self = shift; diff --git a/FS/FS/type_pkgs.pm b/FS/FS/type_pkgs.pm index bf34e7cda..650375524 100644 --- a/FS/FS/type_pkgs.pm +++ b/FS/FS/type_pkgs.pm @@ -83,17 +83,11 @@ sub check { my $error = $self->ut_numbern('typepkgnum') - || $self->ut_number('typenum') - || $self->ut_number('pkgpart') + || $self->ut_foreign_key('typenum', 'agent_type', 'typenum' ) + || $self->ut_foreign_key('pkgpart', 'part_pkg', 'pkgpart' ) ; return $error if $error; - return "Unknown typenum" - unless qsearchs( 'agent_type', { 'typenum' => $self->typenum } ); - - return "Unknown pkgpart" - unless qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } ); - $self->SUPER::check; } @@ -108,6 +102,17 @@ sub part_pkg { qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } ); } +=item agent_type + +Returns the FS::agent_type object associated with this record. + +=cut + +sub agent_type { + my $self = shift; + qsearchs( 'agent_type', { 'typenum' => $self->typenum } ); +} + =cut =back diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 1fed614a2..801c09f8f 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -30,6 +30,7 @@ my $edit_global = 'Edit global package definitions'; my $acl_edit = $curuser->access_right($edit); my $acl_edit_global = $curuser->access_right($edit_global); my $acl_config = $curuser->access_right('Configuration'); #to edit services + #and agent types die "access denied" unless $acl_edit || $acl_edit_global; @@ -174,6 +175,40 @@ push @fields, sub { # $part_pkg->freq_pretty; #.'<BR>' }; +### +# Agent goes here if displayed +### + +#agent type +if ( $acl_edit_global ) { + #really we just want a count, but this is fine unless someone has tons + my @all_agent_types = map {$_->typenum} qsearch('agent_type',{}); + if ( scalar(@all_agent_types) > 1 ) { + push @header, 'Agent types'; + my $typelink = $p. 'edit/agent_type.cgi?'; + push @fields, sub { my $part_pkg = shift; + [ + map { warn $_; + my $agent_type = $_->agent_type; + warn $agent_type; + [ + { 'data' => $agent_type->atype, #escape? + 'align' => 'left', + 'link' => ( $acl_config + ? $typelink. + $agent_type->typenum + : '' + ), + }, + ]; + } + $part_pkg->type_pkgs + ]; + }; + $align .= 'l'; + } +} + #if ( $cgi->param('active') ) { push @header, 'Customer<BR>packages'; my %col = ( |