diff options
-rw-r--r-- | FS/FS/AccessRight.pm | 3 | ||||
-rw-r--r-- | FS/FS/Schema.pm | 6 | ||||
-rw-r--r-- | FS/FS/part_event.pm | 1 | ||||
-rw-r--r-- | FS/FS/part_pkg.pm | 15 | ||||
-rwxr-xr-x | httemplate/browse/part_pkg.cgi | 11 |
5 files changed, 32 insertions, 4 deletions
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm index 4071e9730..5ab6809a4 100644 --- a/FS/FS/AccessRight.pm +++ b/FS/FS/AccessRight.pm @@ -223,6 +223,9 @@ tie my %rights, 'Tie::IxHash', 'Configuration rights' => [ 'Edit advertising sources', { rightname=>'Edit global advertising sources', global=>1 }, + + 'Edit package definitions', + { rightname=>'Edit global package definitions', global=>1 }, 'Edit billing events', { rightname=>'Edit global billing events', global=>1 }, diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index aebe5de63..1ddaca0eb 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -862,10 +862,12 @@ sub tables_hashref { 'classnum', 'int', 'NULL', '', '', '', 'pay_weight', 'real', 'NULL', '', '', '', 'credit_weight', 'real', 'NULL', '', '', '', + 'agentnum', 'int', 'NULL', '', '', '', + ], 'primary_key' => 'pkgpart', 'unique' => [], - 'index' => [ [ 'promo_code' ], [ 'disabled' ] ], + 'index' => [ [ 'promo_code' ], [ 'disabled' ], [ 'agentnum' ], ], }, # 'part_title' => { @@ -900,7 +902,7 @@ sub tables_hashref { ], 'primary_key' => 'refnum', 'unique' => [], - 'index' => [ ['disabled'] ], + 'index' => [ ['disabled'], ['agentnum'], ], }, 'part_svc' => { diff --git a/FS/FS/part_event.pm b/FS/FS/part_event.pm index 09104cd49..d0ab65e3f 100644 --- a/FS/FS/part_event.pm +++ b/FS/FS/part_event.pm @@ -138,6 +138,7 @@ sub check { || $self->ut_number('weight') || $self->ut_alpha('action') || $self->ut_enum('disabled', [ '', 'Y' ] ) + || $self->ut_agentnum_acl('agentnum', 'Edit global billing events') ; return $error if $error; diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index fad7af2f9..84502b745 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -13,6 +13,7 @@ use FS::agent_type; use FS::type_pkgs; use FS::part_pkg_option; use FS::pkg_class; +use FS::agent; @ISA = qw( FS::m2m_Common FS::Record ); # FS::option_Common ); # this can use option_Common # when all the plandata bs is @@ -85,6 +86,8 @@ inherits from FS::Record. The following fields are currently supported: =item credit_weight - Weight (relative to other package definitions) that controls credit application to specific line items. +=item agentnum - Optional agentnum (see L<FS::agent>) + =back =head1 METHODS @@ -449,6 +452,7 @@ sub check { || $self->ut_enum('disabled', [ '', 'Y' ] ) || $self->ut_floatn('pay_weight') || $self->ut_floatn('credit_weight') + || $self->ut_agentnum_acl('agentnum', 'Edit global package definitions') || $self->SUPER::check ; return $error if $error; @@ -501,6 +505,17 @@ sub classname { : ''; } +=item agent + +Returns the associated agent for this event, if any, as an FS::agent object. + +=cut + +sub agent { + my $self = shift; + qsearchs('agent', { 'agentnum' => $self->agentnum } ); +} + =item pkg_svc Returns all FS::pkg_svc objects (see L<FS::pkg_svc>) for this package diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 0b83fc000..40f6b3d71 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -5,6 +5,9 @@ 'name' => 'package definitions', 'disableable' => 1, 'disabled_statuspos' => 3, + 'agent_virt' => 1, + 'agent_null_right' => 'Edit global package definitions', + 'agent_pos' => 4, 'query' => { 'select' => $select, 'table' => 'part_pkg', 'hashref' => {}, @@ -20,7 +23,8 @@ <%init> die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + unless $FS::CurrentUser::CurrentUser->access_right('Edit package definitions') + || $FS::CurrentUser::CurrentUser->access_right('Edit global package definitions'); my $select = '*'; my $orderby = 'pkgpart'; @@ -220,6 +224,9 @@ $align .= 'lrl'; #rr'; # -------- -my $count_query = 'SELECT COUNT(*) FROM part_pkg'; +my $count_query = 'SELECT COUNT(*) FROM part_pkg WHERE '. + $FS::CurrentUser::CurrentUser->agentnums_sql( + 'null_right' => 'Edit global package definitions', + ); </%init> |