From d6dbf288fd8ea42ebd5171d80817356248cf22ce Mon Sep 17 00:00:00 2001 From: jeff Date: Sat, 13 Oct 2007 17:33:48 +0000 Subject: [PATCH] correct agent_defaultpkg handling --- httemplate/edit/part_pkg.cgi | 4 ++-- httemplate/edit/process/part_pkg.cgi | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index 98ce71a28..7c6115423 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -162,7 +162,7 @@ Line-item revenue recognition -% if ( $cgi->param('clone') ) { +% if ( $cgi->param('clone') || $conf->exists('agent_defaultpkg') ) { @@ -178,7 +178,7 @@ Line-item revenue recognition 'table' => 'agent_type', 'name_col' => 'atype', 'value' => \@agent_type, - 'empty_label' => '(none)', + 'empty_label' => 'select agent types', 'element_etc' => 'multiple size="10"', ) %> diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index fd7b17567..5d9c2355b 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -1,6 +1,7 @@ % % %my $dbh = dbh; +%my $conf = new FS::Conf; % %my $pkgpart = $cgi->param('pkgpart'); % @@ -42,6 +43,9 @@ % } fields('part_pkg') %} ); % +%my $oldAutoCommit = $FS::UID::AutoCommit; +%local $FS::UID::AutoCommit = 0; +% %my %pkg_svc = map { $_ => scalar($cgi->param("pkg_svc$_")) } % map { $_->svcpart } % qsearch('part_svc', {} ); @@ -71,7 +75,7 @@ % $pkgpart = $new->pkgpart; %} % -%unless ($error) { +%unless ( $error || $conf->exists('agent_defaultpkg') ) { % my $error = $new->process_m2m( % 'link_table' => 'type_pkgs', % 'target_table' => 'agent_type', @@ -79,11 +83,14 @@ % ); %} %if ( $error ) { +% $dbh->rollback if $oldAutoCommit; % $cgi->param('error', $error ); % print $cgi->redirect(popurl(2). "part_pkg.cgi?". $cgi->query_string ); %} elsif ( $custnum ) { +% $dbh->commit or die $dbh->errstr if $oldAutoCommit; % print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum"); %} else { +% $dbh->commit or die $dbh->errstr if $oldAutoCommit; % print $cgi->redirect(popurl(3). "browse/part_pkg.cgi"); %} % -- 2.11.0