diff options
author | Ivan Kohler <ivan@freeside.biz> | 2014-12-05 14:24:01 -0800 |
---|---|---|
committer | Jeremy Davis <jeremyd@freeside.biz> | 2014-12-09 13:51:16 -0500 |
commit | 6199f898a744f2cc2f9f03450d49286866a3f4d0 (patch) | |
tree | c5956aba2e89a768f0f7bd0031518c982628d070 /httemplate/browse | |
parent | fa868107440f645205e7943fd370fb48e677f091 (diff) |
disable agent types, RT#31446
Diffstat (limited to 'httemplate/browse')
-rwxr-xr-x | httemplate/browse/agent_type.cgi | 88 | ||||
-rwxr-xr-x | httemplate/browse/part_pkg.cgi | 13 |
2 files changed, 52 insertions, 49 deletions
diff --git a/httemplate/browse/agent_type.cgi b/httemplate/browse/agent_type.cgi index 7711dccf7..0c011ceed 100755 --- a/httemplate/browse/agent_type.cgi +++ b/httemplate/browse/agent_type.cgi @@ -1,27 +1,28 @@ -<% include( 'elements/browse.html', - 'title' => 'Agent Types', - 'menubar' => [ 'Agents' =>"${p}browse/agent.cgi", ], - 'html_init' => $html_init, - 'name' => 'agent types', - 'query' => { 'table' => 'agent_type', - 'hashref' => {}, - 'order_by' => 'ORDER BY typenum', # 'ORDER BY atype', - }, - 'count_query' => $count_query, - 'header' => [ '#', - 'Agent Type', - 'Packages', - ], - 'fields' => [ 'typenum', - 'atype', - $packages_sub, - ], - 'links' => [ $link, - $link, - '', - ], - ) -%> +<& elements/browse.html, + 'title' => 'Agent Types', + 'menubar' => [ 'Agents' => "${p}browse/agent.cgi" ], + 'html_init' => $html_init, + 'name' => 'agent types', + 'disableable' => 1, + 'disabled_statuspos' => 2, + 'query' => { 'table' => 'agent_type', + 'hashref' => {}, + 'order_by' => 'ORDER BY typenum', # atype? + }, + 'count_query' => $count_query, + 'header' => [ '#', + 'Agent Type', + 'Packages', + ], + 'fields' => [ 'typenum', + 'atype', + $packages_sub, + ], + 'links' => [ $link, + $link, + '', + ], +&> <%init> die "access denied" @@ -36,25 +37,26 @@ my $count_query = 'SELECT COUNT(*) FROM agent_type'; #false laziness w/access_user.html my $packages_sub = sub { -my $agent_type = shift; - -[ map { - my $type_pkgs = $_; - #my $part_pkg = $type_pkgs->part_pkg; - [ - { - #'data' => $part_pkg->pkg. ' - '. $part_pkg->comment, - 'data' => encode_entities($type_pkgs->pkg). ' - '. - ( $type_pkgs->custom ? '(CUSTOM) ' : '' ). - encode_entities($type_pkgs->comment), - 'align' => 'left', - 'link' => $p. 'edit/part_pkg.cgi?'. $type_pkgs->pkgpart, - }, - ]; - } - - $agent_type->type_pkgs_enabled -]; + my $agent_type = shift; + my @type_pkgs = $agent_type->type_pkgs_enabled; + return '(lots; edit agent type to view)' if scalar(@type_pkgs) > 32; + + [ map { + my $type_pkgs = $_; + #my $part_pkg = $type_pkgs->part_pkg; + [ + { + #'data' => $part_pkg->pkg. ' - '. $part_pkg->comment, + 'data' => encode_entities($type_pkgs->pkg). ' - '. + ( $type_pkgs->custom ? '(CUSTOM) ' : '' ). + encode_entities($type_pkgs->comment), + 'align' => 'left', + 'link' => $p. 'edit/part_pkg.cgi?'. $type_pkgs->pkgpart, + }, + ]; + } + @type_pkgs + ]; }; diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 11487fa5f..1fc0c49a3 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -77,11 +77,11 @@ if ( $cgi->param('classnum') =~ /^(\d+)$/ ) { $cgi->delete('classnum'); if ( $cgi->param('missing_recur_fee') ) { - push @where, "0 = ( SELECT COUNT(*) FROM part_pkg_option - WHERE optionname = 'recur_fee' - AND part_pkg_option.pkgpart = part_pkg.pkgpart - AND CAST( optionvalue AS NUMERIC ) > 0 - )"; + push @where, "NOT EXISTS ( SELECT 1 FROM part_pkg_option + WHERE optionname = 'recur_fee' + AND part_pkg_option.pkgpart = part_pkg.pkgpart + AND CAST( optionvalue AS NUMERIC ) > 0 + )"; } if ( $cgi->param('family') =~ /^(\d+)$/ ) { @@ -405,7 +405,8 @@ push @fields, sub { #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',{}); + my @all_agent_types = map {$_->typenum} + qsearch('agent_type', { 'disabled'=>'' }); if ( scalar(@all_agent_types) > 1 ) { push @header, 'Agent types'; my $typelink = $p. 'edit/agent_type.cgi?'; |