diff options
author | Ivan Kohler <ivan@freeside.biz> | 2014-12-05 14:24:01 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2014-12-05 14:24:01 -0800 |
commit | e68a2a20972de41485c438c46d197b5abeee3267 (patch) | |
tree | c1ec35d55fb428e9114bd63e70ac1d67ff267fd8 | |
parent | 289958e5f402e896e561e6911081b9cd36c4c098 (diff) |
disable agent types, RT#31446
-rw-r--r-- | FS/FS/Schema.pm | 7 | ||||
-rw-r--r-- | FS/FS/agent_type.pm | 17 | ||||
-rwxr-xr-x | httemplate/browse/agent_type.cgi | 88 | ||||
-rwxr-xr-x | httemplate/browse/part_pkg.cgi | 13 | ||||
-rwxr-xr-x | httemplate/edit/agent.cgi | 2 | ||||
-rwxr-xr-x | httemplate/edit/agent_type.cgi | 26 | ||||
-rwxr-xr-x | httemplate/edit/part_pkg.cgi | 3 | ||||
-rw-r--r-- | httemplate/elements/tr-select-agent_type.html | 11 |
8 files changed, 97 insertions, 70 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 91dfc5d97..492f8e2b7 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -556,12 +556,13 @@ sub tables_hashref { 'agent_type' => { 'columns' => [ - 'typenum', 'serial', '', '', '', '', - 'atype', 'varchar', '', $char_d, '', '', + 'typenum', 'serial', '', '', '', '', + 'atype', 'varchar', '', $char_d, '', '', + 'disabled', 'char', 'NULL', 1, '', '', ], 'primary_key' => 'typenum', 'unique' => [], - 'index' => [], + 'index' => [ ['disabled'] ], }, 'type_pkgs' => { diff --git a/FS/FS/agent_type.pm b/FS/FS/agent_type.pm index 5d6b94e0c..e0f749500 100644 --- a/FS/FS/agent_type.pm +++ b/FS/FS/agent_type.pm @@ -45,9 +45,17 @@ FS::Record. The following fields are currently supported: =over 4 -=item typenum - primary key (assigned automatically for new agent types) +=item typenum -=item atype - Text name of this agent type +primary key (assigned automatically for new agent types) + +=item atype + +Text name of this agent type + +=item disabled + +Disabled flag, empty or 'Y' =back @@ -103,8 +111,9 @@ sub check { my $self = shift; $self->ut_numbern('typenum') - or $self->ut_text('atype') - or $self->SUPER::check; + || $self->ut_text('atype') + || $self->ut_enum('disabled', [ '', 'Y' ] ) + || $self->SUPER::check; } 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 1eb55c88a..87aa79255 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+)$/ ) { @@ -419,7 +419,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?'; diff --git a/httemplate/edit/agent.cgi b/httemplate/edit/agent.cgi index 15da2f043..c4963e470 100755 --- a/httemplate/edit/agent.cgi +++ b/httemplate/edit/agent.cgi @@ -35,7 +35,7 @@ <TH ALIGN="right">Agent type</TH> <TD> <SELECT NAME="typenum" SIZE=1> -% foreach my $agent_type (qsearch('agent_type',{})) { +% foreach my $agent_type ( qsearch('agent_type', { 'disabled'=>'' }) ) { <OPTION VALUE="<% $agent_type->typenum %>"<% ( $agent->typenum && ( $agent->typenum == $agent_type->typenum ) ) ? ' SELECTED' : '' %>> <% $agent_type->getfield('typenum') %>: <% $agent_type->getfield('atype') %> diff --git a/httemplate/edit/agent_type.cgi b/httemplate/edit/agent_type.cgi index b75757fb1..f16d76ce0 100755 --- a/httemplate/edit/agent_type.cgi +++ b/httemplate/edit/agent_type.cgi @@ -7,15 +7,31 @@ <FORM ACTION="<% popurl(1) %>process/agent_type.cgi" METHOD=POST> <INPUT TYPE="hidden" NAME="typenum" VALUE="<% $agent_type->typenum %>"> + +<FONT CLASS="fsinnerbox-title"> Agent Type #<% $agent_type->typenum || "(NEW)" %> +</FONT> + +<TABLE CLASS="fsinnerbox"> + + <TR> + <TH ALIGN="right">Agent Type</TH> + <TD><INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="<% $agent_type->atype %>"></TD> + </TR> + + <TR> + <TH ALIGN="right">Disable</TH> + <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y" <% $agent_type->disabled eq 'Y' ? ' CHECKED' : '' %>></TD> + </TR> + +<TABLE> <BR> -Agent Type -<INPUT TYPE="text" NAME="atype" SIZE=32 VALUE="<% $agent_type->atype %>"> -<BR><BR> +<FONT CLASS="fsinnerbox-title"> +Package definitions that agents of this type can sell +</FONT> -Select which packages agents of this type may sell to customers<BR> -<% ntable("#cccccc", 2) %><TR><TD> +<TABLE CLASS="fsinnerbox"><TR><TD> <% include('/elements/checkboxes-table.html', 'source_obj' => $agent_type, 'link_table' => 'type_pkgs', diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index 2ae9df3ec..c4db83aee 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -654,8 +654,7 @@ my $new_callback = sub { my $conf = new FS::Conf; if ( $conf->exists('agent_defaultpkg') ) { - #my @all_agent_types = map {$_->typenum} qsearch('agent_type',{}); - @agent_type = map {$_->typenum} qsearch('agent_type',{}); + @agent_type = map {$_->typenum} qsearch('agent_type', { 'disabled'=>'' }); } $options{'suspend_bill'}=1 if $conf->exists('part_pkg-default_suspend_bill'); diff --git a/httemplate/elements/tr-select-agent_type.html b/httemplate/elements/tr-select-agent_type.html index 9ea943b51..3e6ce0752 100644 --- a/httemplate/elements/tr-select-agent_type.html +++ b/httemplate/elements/tr-select-agent_type.html @@ -7,11 +7,10 @@ <TR> <TD ALIGN="right"><% $opt{'label'} || 'Agent Type' %></TD> <TD> - <% include( '/elements/select-agent_type.html', - 'curr_value' => $typenum, - %opt, - ) - %> + <& /elements/select-agent_type.html, + 'curr_value' => $typenum, + %opt, + &> </TD> </TR> @@ -22,6 +21,6 @@ my %opt = @_; my $typenum = $opt{'curr_value'} || $opt{'value'}; -my @agent_types = qsearch('agent_type', {}); +my @agent_types = qsearch('agent_type', { 'disabled' => '' }); </%init> |