projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3b5ccff
)
forget caching, instead scoop up cust_pkg and part_pkg in one query, RT#5083
author
ivan
<ivan>
Mon, 30 Mar 2009 01:05:04 +0000
(
01:05
+0000)
committer
ivan
<ivan>
Mon, 30 Mar 2009 01:05:04 +0000
(
01:05
+0000)
FS/FS/cust_main.pm
patch
|
blob
|
history
httemplate/view/cust_main/packages.html
patch
|
blob
|
history
diff --git
a/FS/FS/cust_main.pm
b/FS/FS/cust_main.pm
index
73cf826
..
1766b45
100644
(file)
--- a/
FS/FS/cust_main.pm
+++ b/
FS/FS/cust_main.pm
@@
-1809,7
+1809,7
@@
sub has_ship_address {
scalar( grep { $self->getfield("ship_$_") ne '' } $self->addr_fields );
}
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.
Returns all packages (see L<FS::cust_pkg>) for this customer.
@@
-1817,14
+1817,19
@@
Returns all packages (see L<FS::cust_pkg>) for this customer.
sub all_pkgs {
my $self = shift;
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 {
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;
}
sort sort_packages @cust_pkg;
@@
-1851,7
+1856,7
@@
sub cust_location {
qsearch('cust_location', { 'custnum' => $self->custnum } );
}
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.
Returns all non-cancelled packages (see L<FS::cust_pkg>) for this customer.
@@
-1859,6
+1864,7
@@
Returns all non-cancelled packages (see L<FS::cust_pkg>) for this customer.
sub ncancelled_pkgs {
my $self = shift;
sub ncancelled_pkgs {
my $self = shift;
+ my $extra_qsearch = ref($_[0]) ? shift : {};
return $self->num_ncancelled_pkgs unless wantarray;
return $self->num_ncancelled_pkgs unless wantarray;
@@
-1877,16
+1883,13
@@
sub ncancelled_pkgs {
$self->custnum. "\n"
if $DEBUG > 1;
$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;
}
sort sort_packages @cust_pkg;
diff --git
a/httemplate/view/cust_main/packages.html
b/httemplate/view/cust_main/packages.html
index
9b1d5b3
..
56bc63f
100755
(executable)
--- a/
httemplate/view/cust_main/packages.html
+++ b/
httemplate/view/cust_main/packages.html
@@
-76,7
+76,7
@@
Current packages
<TH CLASS="grid" BGCOLOR="#cccccc">Services</TH>
</TR>
<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 ) {
% foreach my $cust_pkg (@$packages) {
%
% if ( $bgcolor eq $bgcolor1 ) {
@@
-85,18
+85,15
@@
Current packages
% $bgcolor = $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,
%
% my %iopt = (
% 'bgcolor' => $bgcolor,
% 'cust_pkg' => $cust_pkg,
-% 'part_pkg' => $
part_pkg{$cust_pkg->pkgpart}
,
+% 'part_pkg' => $
cust_pkg->part_pkg
,
% %conf_opt,
% );
%
% %conf_opt,
% );
%
-% my $oldDEBUG = $FS::cust_pkg::DEBUG;
-% $FS::cust_pkg::DEBUG = 2;
<!--pkgnum: <% $cust_pkg->pkgnum %>-->
<TR>
<!--pkgnum: <% $cust_pkg->pkgnum %>-->
<TR>
@@
-108,8
+105,6
@@
Current packages
<% include('packages/services.html', %iopt) %>
</TR>
<% include('packages/services.html', %iopt) %>
</TR>
-% $FS::cust_pkg::DEBUG = $oldDEBUG;
-
% }
</TABLE>
% }
</TABLE>
@@
-174,7
+169,10
@@
sub get_packages {
$method = 'all_pkgs';
}
$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') ) {
my $num_old_packages = scalar(@packages);
unless ( $cgi->param('showoldpackages') ) {