X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fagent_type.pm;h=2660bb4a3a84ef84f0a375feb50f232deb8059cb;hp=988533ae347903ba766bd7f08154be82f7f5eb85;hb=20f38e4c256094bd938b732950e8f93319f851a5;hpb=c0567c688084e89fcd11bf82348b6c418f1254ac diff --git a/FS/FS/agent_type.pm b/FS/FS/agent_type.pm index 988533ae3..2660bb4a3 100644 --- a/FS/FS/agent_type.pm +++ b/FS/FS/agent_type.pm @@ -3,10 +3,11 @@ package FS::agent_type; use strict; use vars qw( @ISA ); use FS::Record qw( qsearch ); +use FS::m2m_Common; use FS::agent; use FS::type_pkgs; -@ISA = qw( FS::Record ); +@ISA = qw( FS::m2m_Common FS::Record ); =head1 NAME @@ -102,7 +103,8 @@ sub check { my $self = shift; $self->ut_numbern('typenum') - or $self->ut_text('atype'); + or $self->ut_text('atype') + or $self->SUPER::check; } @@ -134,6 +136,27 @@ sub type_pkgs { qsearch('type_pkgs', { 'typenum' => $self->typenum } ); } +=item type_pkgs_enabled + +Returns all FS::type_pkg objects (see L) that link to enabled +package definitions (see L). + +An additional strange feature is that the returned type_pkg objects also have +all fields of the associated part_pkg object. + +=cut + +sub type_pkgs_enabled { + my $self = shift; + qsearch({ + 'table' => 'type_pkgs', + 'addl_from' => 'JOIN part_pkg USING ( pkgpart )', + 'hashref' => { 'typenum' => $self->typenum }, + 'extra_sql' => " AND ( disabled = '' OR disabled IS NULL )". + " ORDER BY pkg", + }); +} + =item pkgpart Returns the pkgpart of all package definitions (see L) for this @@ -148,11 +171,14 @@ sub pkgpart { =back -=head1 VERSION +=head1 BUGS -$Id: agent_type.pm,v 1.1 1999-08-04 09:03:53 ivan Exp $ +type_pkgs_enabled should order itself by something (pkg?) -=head1 BUGS +type_pkgs_enabled should populate something that caches for the part_pkg method +rather than add fields to this object, right? In fact we need a "poop" object +framework that does that automatically for any joined search at some point.... +right? =head1 SEE ALSO