fix agent type selection, RT#28804
authorIvan Kohler <ivan@freeside.biz>
Wed, 7 May 2014 23:36:00 +0000 (16:36 -0700)
committerIvan Kohler <ivan@freeside.biz>
Wed, 7 May 2014 23:36:00 +0000 (16:36 -0700)
FS/FS/part_pkg.pm
httemplate/edit/process/part_pkg.cgi
httemplate/elements/tr-select-agent_type.html

index deba655..b62b52d 100644 (file)
@@ -218,23 +218,6 @@ sub insert {
     }
   }
 
-  my $conf = new FS::Conf;
-  if ( $conf->exists('agent_defaultpkg') ) {
-    warn "  agent_defaultpkg set; allowing all agents to purchase package"
-      if $DEBUG;
-    foreach my $agent_type ( qsearch('agent_type', {} ) ) {
-      my $type_pkgs = new FS::type_pkgs({
-        'typenum' => $agent_type->typenum,
-        'pkgpart' => $self->pkgpart,
-      });
-      my $error = $type_pkgs->insert;
-      if ( $error ) {
-        $dbh->rollback if $oldAutoCommit;
-        return $error;
-      }
-    }
-  }
-
   warn "  inserting part_pkg_taxoverride records" if $DEBUG;
   my %overrides = %{ $options{'tax_overrides'} || {} };
   foreach my $usage_class ( keys %overrides ) {
index 69138bc..8ea39e1 100755 (executable)
@@ -50,8 +50,7 @@ my $precheck_callback = sub {
   }
   return "At least one agent type must be specified."
     unless scalar(@agents)
-           || ( $cgi->param('clone') && $cgi->param('clone') =~ /^\d+$/ )
-           || ( !$cgi->param('pkgpart') && $conf->exists('agent-defaultpkg') )
+           #wtf? || ( $cgi->param('clone') && $cgi->param('clone') =~ /^\d+$/ )
            || $cgi->param('disabled')
            || $cgi->param('agentnum');
 
@@ -251,18 +250,16 @@ foreach my $override_class ($cgi->param) {
 
 my $conf = new FS::Conf;
 
-if ( $cgi->param('pkgpart') || ! $conf->exists('agent_defaultpkg') ) {
-  my @agents = ();
-  foreach ($cgi->param('agent_type')) {
-    /^(\d+)$/;
-    push @agents, $1 if $1;
-  }
-  push @process_m2m, {
-    'link_table'   => 'type_pkgs',
-    'target_table' => 'agent_type',
-    'params'       => \@agents,
-  };
+my @agents = ();
+foreach ($cgi->param('agent_type')) {
+  /^(\d+)$/;
+  push @agents, $1 if $1;
 }
+push @process_m2m, {
+  'link_table'   => 'type_pkgs',
+  'target_table' => 'agent_type',
+  'params'       => \@agents,
+};
 
 my $targets = FS::part_pkg_usageprice->targets;
 foreach my $amount_param ( grep /^usagepricepart(\d+)_amount$/, $cgi->param ) {
index 3fcbcd3..400cb4e 100644 (file)
@@ -1,8 +1,8 @@
-%#% if ( scalar(@agent_types) == 1 ) { 
-%#
-%#  <INPUT TYPE="hidden" NAME="<% $opt{'field'} || 'typenum' %>" VALUE="<% $agent_types[0]->typenum %>">
-%#
-%#% } else { 
+% if ( scalar(@agent_types) == 1 ) { 
+
+  <INPUT TYPE="hidden" NAME="<% $opt{'field'} || 'typenum' %>" VALUE="<% $agent_types[0]->typenum %>">
+
+% } else { 
 
   <TR>
     <TD ALIGN="right"><% $opt{'label'} || 'Agent Type' %></TD>
@@ -15,7 +15,7 @@
     </TD>
   </TR>
 
-%#% } 
+% } 
 
 <%init>