diff options
author | jeff <jeff> | 2007-02-08 01:46:45 +0000 |
---|---|---|
committer | jeff <jeff> | 2007-02-08 01:46:45 +0000 |
commit | 83a6a677f62ca501011d9bac6371344dbb5a13b3 (patch) | |
tree | 1608249d6e0855dd24c3c9a7609ddad6ba3a0590 | |
parent | 10fdcf4c76e4dd14f7fb738665e3fb401af3c28a (diff) |
agent type on package add/edit (ticket 1446)
-rw-r--r-- | FS/FS/part_pkg.pm | 2 | ||||
-rw-r--r-- | htetc/handler.pl | 2 | ||||
-rwxr-xr-x | httemplate/edit/part_pkg.cgi | 33 | ||||
-rwxr-xr-x | httemplate/edit/process/part_pkg.cgi | 13 | ||||
-rw-r--r-- | httemplate/elements/select-table.html | 10 |
5 files changed, 52 insertions, 8 deletions
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index 73413f89f..e4c13aade 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -14,7 +14,7 @@ use FS::type_pkgs; use FS::part_pkg_option; use FS::pkg_class; -@ISA = qw( FS::Record ); # FS::option_Common ); # this can use option_Common +@ISA = qw( FS::m2m_Common FS::Record ); # FS::option_Common ); # this can use option_Common # when all the plandata bs is # gone diff --git a/htetc/handler.pl b/htetc/handler.pl index f742e91b9..164da3702 100644 --- a/htetc/handler.pl +++ b/htetc/handler.pl @@ -119,7 +119,7 @@ sub handler use Chart::LinesPoints; use Chart::Mountain; use Color::Scheme; - use HTML::Widgets::SelectLayers 0.06; + use HTML::Widgets::SelectLayers 0.07; use Locale::Country; use FS; use FS::UID qw(cgisuidsetup dbh getotaker datasrc driver_name); diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index f970508da..a84fafa1b 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -14,10 +14,12 @@ %my ($query) = $cgi->keywords; % %my $part_pkg = ''; +%my @agent_type = (); %if ( $cgi->param('error') ) { % $part_pkg = new FS::part_pkg ( { % map { $_, scalar($cgi->param($_)) } fields('part_pkg') % } ); +% (@agent_type) = $cgi->param('agent_type'); %} % %my $action = ''; @@ -30,6 +32,8 @@ % $part_pkg ||= $clone_part_pkg->clone; % $part_pkg->disabled('Y'); #isn't sticky on errors %} elsif ( $query && $query =~ /^(\d+)$/ ) { +% (@agent_type) = map {$_->typenum} qsearch('type_pkgs',{'pkgpart'=>$1}) +% unless $part_pkg; % $part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1}); % $pkgpart = $part_pkg->pkgpart; %} else { @@ -153,6 +157,25 @@ Line-item revenue recognition % } </TABLE> +</TD><TD VALIGN="top"> + +Reseller information +<% ntable("#cccccc", 2) %> + <TR> + <TD ALIGN="right"><% 'Agent Types' %></TD> + <TD> + <% include( '/elements/select-table.html', + 'element_name' => 'agent_type', + 'table' => 'agent_type', + 'name_col' => 'atype', + 'value' => \@agent_type, + 'empty_label' => '(none)', + 'element_etc' => 'multiple size="10"', + ) + %> + </TD> + </TR> +</TABLE> </TD></TR></TABLE> % % @@ -248,7 +271,7 @@ Line-item revenue recognition %#} else { %# push @fixups, 'taxclass'; #hidden %#} -%my @form_elements = ( 'classnum', 'taxclass' ); +%my @form_elements = ( 'classnum', 'taxclass', 'agent_type' ); % %my @form_radio = (); %if ( dbdef->table('pkg_svc')->column('primary_svc') ) { @@ -267,7 +290,7 @@ Line-item revenue recognition % 'form_action' => 'process/part_pkg.cgi', % 'form_elements' => \@form_elements, % 'form_text' => [ qw(pkg comment promo_code clone pkgnum pkgpart), -% qw(pay_weight credit_weight), #keys(%weight), +% qw(pay_weight credit_weight), % @fixups, % ], % 'form_checkbox' => [ qw(setuptax recurtax disabled) ], @@ -305,7 +328,7 @@ Line-item revenue recognition % ( exists($plandata{$field}) % ? $plandata{$field} % : $href->{$field}{'default'} ). -% qq!" onChange="fchanged(this)">!; +% qq!">!; % } elsif ( $href->{$field}{'type'} eq 'checkbox' ) { % $html .= qq!<INPUT TYPE="checkbox" NAME="$field" VALUE=1 !. % ( exists($plandata{$field}) && $plandata{$field} @@ -316,7 +339,7 @@ Line-item revenue recognition % $html .= '<SELECT'; % $html .= ' MULTIPLE' % if $href->{$field}{'type'} eq 'select_multiple'; -% $html .= qq! NAME="$field" onChange="fchanged(this)">!; +% $html .= qq! NAME="$field">!; % % if ( $href->{$field}{'select_table'} ) { % foreach my $record ( @@ -360,7 +383,7 @@ Line-item revenue recognition % % $html .= '<INPUT TYPE="submit" VALUE="'. % ( $hashref->{pkgpart} ? "Apply changes" : "Add package" ). -% '" onClick="fchanged(this)">'; +% '">'; % % $html; % diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index 204c751d9..1158222b6 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -17,6 +17,12 @@ % $cgi->param($_, '') unless defined $cgi->param($_); %} % +%my @agents; +%foreach ($cgi->param('agent_type')) { +% /^(\d+)$/; +% push @agents, $1 if $1; +%} +% %my $new = new FS::part_pkg ( { % map { % $_ => scalar($cgi->param($_)); @@ -49,6 +55,13 @@ % $pkgpart = $new->pkgpart; %} % +%unless ($error) { +% my $error = $new->process_m2m( +% 'link_table' => 'type_pkgs', +% 'target_table' => 'agent_type', +% 'params' => \@agents, +% ); +%} %if ( $error ) { % $cgi->param('error', $error ); % print $cgi->redirect(popurl(2). "part_pkg.cgi?". $cgi->query_string ); diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html index 0c3c00563..3235ef627 100644 --- a/httemplate/elements/select-table.html +++ b/httemplate/elements/select-table.html @@ -9,8 +9,11 @@ <OPTION VALUE=""><% $opt{'empty_label'} || 'all' %> % foreach my $record ( sort { $a->$name_col() cmp $b->$name_col() } @records ) { +% my $matches = 0; +% ref($opt{'value'}) ? (exists($opt{'value'}->{$record->$key()}) and $matches=1) +% : ($opt{'value'} == $record->$key() and $matches=1); - <OPTION VALUE="<% $record->$key() %>"<% $opt{'value'} == $record->$key() ? ' SELECTED' : '' %>><% $record->$name_col() %> + <OPTION VALUE="<% $record->$key() %>"<% $matches ? ' SELECTED' : '' %>><% $record->$name_col() %> % } @@ -59,6 +62,7 @@ if ( $opt{records} ) { } unless ( ! $opt{value} + or ref($opt{value}) or ! exists( $opt{hashref}->{disabled} ) #?? or grep { $opt{value} == $_->$key() } @records ) { @@ -72,6 +76,10 @@ unless ( ! $opt{value} push @records, $record if $record; } +if ( ref( $opt{value} ) eq 'ARRAY' ) { + $opt{value} = { map { $_ => 1 } @{$opt{value}} }; +} + my @pre_options = $opt{pre_options} ? @{ $opt{pre_options} } : (); </%init> |