backup the schema for tables we don't need the data from. RT#85959
[freeside.git] / FS / FS / agent_type.pm
index 2660bb4..e0f7495 100644 (file)
@@ -2,7 +2,7 @@ package FS::agent_type;
 
 use strict;
 use vars qw( @ISA );
-use FS::Record qw( qsearch );
+use FS::Record qw( qsearch dbh );
 use FS::m2m_Common;
 use FS::agent;
 use FS::type_pkgs;
@@ -45,9 +45,17 @@ FS::Record.  The following fields are currently supported:
 
 =over 4
 
-=item typenum - primary key (assigned automatically for new agent types)
+=item typenum
 
-=item atype - Text name of this agent type
+primary key (assigned automatically for new agent types)
+
+=item atype
+
+Text name of this agent type
+
+=item disabled
+
+Disabled flag, empty or 'Y'
 
 =back
 
@@ -103,8 +111,9 @@ sub check {
   my $self = shift;
 
   $self->ut_numbern('typenum')
-  or $self->ut_text('atype')
-  or $self->SUPER::check;
+    || $self->ut_text('atype')
+    || $self->ut_enum('disabled', [ '', 'Y' ] )
+    || $self->SUPER::check;
 
 }
 
@@ -119,9 +128,7 @@ L<FS::part_pkg>.
 sub pkgpart_hashref {
   my $self = shift;
   my %pkgpart;
-  #$pkgpart{$_}++ foreach $self->pkgpart;
-  # not compatible w/5.004_04 (fixed in 5.004_05)
-  foreach ( $self->pkgpart ) { $pkgpart{$_}++; }
+  $pkgpart{$_}++ foreach $self->pkgpart;
   \%pkgpart;
 }
 
@@ -166,7 +173,13 @@ agent type.
 
 sub pkgpart {
   my $self = shift;
-  map $_->pkgpart, $self->type_pkgs;
+
+  #map $_->pkgpart, $self->type_pkgs;
+
+  my $sql = 'SELECT pkgpart FROM type_pkgs WHERE typenum = ?';
+  my $sth = dbh->prepare($sql)    or die  dbh->errstr;
+  $sth->execute( $self->typenum ) or die $sth->errstr;
+  map $_->[0], @{ $sth->fetchall_arrayref };
 }
 
 =back