package FS::part_pkg;
use strict;
-use vars qw( @ISA %plans $DEBUG );
+use vars qw( @ISA %plans $DEBUG $setup_hack );
use Carp qw(carp cluck confess);
use Scalar::Util qw( blessed );
use Time::Local qw( timelocal_nocheck );
@ISA = qw( FS::m2m_Common FS::option_Common );
$DEBUG = 0;
+$setup_hack = 0;
=head1 NAME
'part_pkg_taxproduct',
'taxproductnum'
)
- || $self->ut_agentnum_acl('agentnum', \@null_agentnum_right)
+ || ( $setup_hack
+ ? $self->ut_foreign_keyn('agentnum', 'agent', 'agentnum' )
+ : $self->ut_agentnum_acl('agentnum', \@null_agentnum_right)
+ )
|| $self->SUPER::check
;
return $error if $error;
=cut
+=item type_pkgs
+
+Returns all FS::type_pkgs objects (see L<FS::type_pkgs>) for this package
+definition.
+
+=cut
+
+sub type_pkgs {
+ my $self = shift;
+ qsearch('type_pkgs', { 'pkgpart' => $self->pkgpart } );
+}
+
sub pkg_svc {
my $self = shift;
sub calc_cancel { 0; }
sub calc_units { 0; }
+#fallback for everything except bulk.pm
+sub hide_svc_detail { 0; }
+
=item format OPTION DATA
Returns data formatted according to the function 'format' described
=cut
sub curuser_pkgs_sql {
- #my($class) = shift;
+ my $class = shift;
+
+ $class->_pkgs_sql( $FS::CurrentUser::CurrentUser->agentnums );
+
+}
+
+=item agent_pkgs_sql AGENT | AGENTNUM, ...
+
+Returns an SQL fragment for searching for packages the provided agent or agents
+can use, either via part_pkg.agentnum directly, or via agent type (see
+L<FS::type_pkgs>).
+
+=cut
+
+sub agent_pkgs_sql {
+ my $class = shift; #i'm a class method, not a sub (the question is... why??)
+ my @agentnums = map { ref($_) ? $_->agentnum : $_ } @_;
+
+ $class->_pkgs_sql(@agentnums); #is this why
+
+}
- my $agentnums = join(',', $FS::CurrentUser::CurrentUser->agentnums);
+sub _pkgs_sql {
+ my( $class, @agentnums ) = @_;
+ my $agentnums = join(',', @agentnums);
"
(