From: jeff Date: Thu, 8 Feb 2007 01:46:45 +0000 (+0000) Subject: agent type on package add/edit (ticket 1446) X-Git-Tag: TRIXBOX_2_6~667 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=83a6a677f62ca501011d9bac6371344dbb5a13b3 agent type on package add/edit (ticket 1446) --- 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 % } + + +Reseller information +<% ntable("#cccccc", 2) %> + + <% 'Agent Types' %> + + <% 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"', + ) + %> + + + % % @@ -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!{$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 .= ''; +% '">'; % % $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 @@