correct agent_defaultpkg handling
authorjeff <jeff>
Sat, 13 Oct 2007 17:33:48 +0000 (17:33 +0000)
committerjeff <jeff>
Sat, 13 Oct 2007 17:33:48 +0000 (17:33 +0000)
httemplate/edit/part_pkg.cgi
httemplate/edit/process/part_pkg.cgi

index 98ce71a..7c61154 100755 (executable)
@@ -162,7 +162,7 @@ Line-item revenue recognition
 
 </TD><TD VALIGN="top">
 
-% if ( $cgi->param('clone') ) {
+% if ( $cgi->param('clone') || $conf->exists('agent_defaultpkg') ) {
 
     <INPUT TYPE="hidden" NAME="agent_type" VALUE="">
 
@@ -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"',
                     )
           %>
index fd7b175..5d9c235 100755 (executable)
@@ -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',
 %  );
 %}
 %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");
 %}
 %