scalar( grep { $self->getfield("ship_$_") ne '' } $self->addr_fields );
}
-=item all_pkgs
+=item all_pkgs [ EXTRA_QSEARCH_PARAMS_HASHREF ]
Returns all packages (see L<FS::cust_pkg>) for this customer.
sub all_pkgs {
my $self = shift;
+ my $extra_qsearch = ref($_[0]) ? shift : {};
- return $self->num_pkgs unless wantarray;
+ return $self->num_pkgs unless wantarray; #XXX doesn't work w/$extra_qsearch
my @cust_pkg = ();
if ( $self->{'_pkgnum'} ) {
@cust_pkg = values %{ $self->{'_pkgnum'}->cache };
} else {
- @cust_pkg = qsearch( 'cust_pkg', { 'custnum' => $self->custnum });
+ @cust_pkg = qsearch({
+ %$extra_qsearch,
+ 'table' => 'cust_pkg',
+ 'hashref' => { 'custnum' => $self->custnum },
+ });
}
sort sort_packages @cust_pkg;
qsearch('cust_location', { 'custnum' => $self->custnum } );
}
-=item ncancelled_pkgs
+=item ncancelled_pkgs [ EXTRA_QSEARCH_PARAMS_HASHREF ]
Returns all non-cancelled packages (see L<FS::cust_pkg>) for this customer.
sub ncancelled_pkgs {
my $self = shift;
+ my $extra_qsearch = ref($_[0]) ? shift : {};
return $self->num_ncancelled_pkgs unless wantarray;
$self->custnum. "\n"
if $DEBUG > 1;
- @cust_pkg =
- qsearch( 'cust_pkg', {
- 'custnum' => $self->custnum,
- 'cancel' => '',
- });
- push @cust_pkg,
- qsearch( 'cust_pkg', {
- 'custnum' => $self->custnum,
- 'cancel' => 0,
- });
+ @cust_pkg = qsearch({
+ %$extra_qsearch,
+ 'table' => 'cust_pkg',
+ 'hashref' => { 'custnum' => $self->custnum },
+ 'extra_sql' => ' AND ( cancel IS NULL OR cancel = 0 ) ',
+ });
+
}
sort sort_packages @cust_pkg;
<TH CLASS="grid" BGCOLOR="#cccccc">Services</TH>
</TR>
-% my %part_pkg = ();
+% local($FS::cust_pkg::DEBUG) = 2;
% foreach my $cust_pkg (@$packages) {
%
% if ( $bgcolor eq $bgcolor1 ) {
% $bgcolor = $bgcolor1;
% }
%
-% $part_pkg{$cust_pkg->pkgpart} ||= $cust_pkg->part_pkg;
-% $cust_pkg->{'_pkgpart'} ||= $part_pkg{$cust_pkg->pkgpart}; #XXX cache kludge
+% $cust_pkg->{'_pkgpart'} = new FS::part_pkg { $cust_pkg->hash }; #quelle klud
%
% my %iopt = (
% 'bgcolor' => $bgcolor,
% 'cust_pkg' => $cust_pkg,
-% 'part_pkg' => $part_pkg{$cust_pkg->pkgpart},
+% 'part_pkg' => $cust_pkg->part_pkg,
% %conf_opt,
% );
%
-% my $oldDEBUG = $FS::cust_pkg::DEBUG;
-% $FS::cust_pkg::DEBUG = 2;
<!--pkgnum: <% $cust_pkg->pkgnum %>-->
<TR>
<% include('packages/services.html', %iopt) %>
</TR>
-% $FS::cust_pkg::DEBUG = $oldDEBUG;
-
% }
</TABLE>
$method = 'all_pkgs';
}
- my @packages = $cust_main->$method();
+ my @packages = $cust_main->$method( {
+ 'select' => 'cust_pkg.*, part_pkg.*',
+ 'addl_from' => 'LEFT JOIN part_pkg USING ( pkgpart )'
+ } );
my $num_old_packages = scalar(@packages);
unless ( $cgi->param('showoldpackages') ) {